Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
Add auth to API routes
Khuram Niaz014b18f9984a
diff --git a/src/auth.config.ts b/src/auth.config.tsindex f870018..be0d666 100644--- a/src/auth.config.ts+++ b/src/auth.config.ts@@ -20,10 +20,10 @@ export const authConfig = {authorized({ auth, request: { nextUrl } }) {const isLoggedIn = !!auth?.user;const isOnDashboard = nextUrl.pathname.startsWith("/dashboard");+ const isApiRoute = nextUrl.pathname.startsWith("/api");- if (isOnDashboard) {- if (isLoggedIn) return true;- return false;+ if (isOnDashboard || isApiRoute) {+ return isLoggedIn;} else if (isLoggedIn) {return Response.redirect(new URL("/dashboard", nextUrl));}diff --git a/src/middleware.ts b/src/middleware.tsindex ec61cc8..389fd8d 100644--- a/src/middleware.ts+++ b/src/middleware.ts@@ -6,8 +6,8 @@ export default NextAuth(authConfig).auth;export const config = {// https://nextjs.org/docs/app/building-your-application/routing/middleware#matchermatcher: [- // "/((?!api|_next/static|_next/image|.*\\.png$).*)","/dashboard","/dashboard/:path*",+ "/api/((?!auth).*)",],};