-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.js
More file actions
40 lines (34 loc) · 1.09 KB
/
middleware.js
File metadata and controls
40 lines (34 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// middleware.js
// SIMPLIFIED: Removed complex database checks that cause deployment issues
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
const isProtectedRoute = createRouteMatcher([
"/dashboard(.*)",
"/resume(.*)",
"/interview(.*)",
"/ai-cover-letter(.*)",
"/onboarding(.*)",
"/resume-analyzer(.*)",
"/job-search(.*)",
"/portfolio-builder(.*)",
"/job-automation(.*)",
]);
export default clerkMiddleware(async (auth, req) => {
const { userId } = await auth();
// Redirect unauthenticated users to sign-in
if (!userId && isProtectedRoute(req)) {
const { redirectToSignIn } = await auth();
return redirectToSignIn({
returnBackUrl: req.url,
});
}
// Let authenticated users through
// Onboarding checks are now handled client-side to avoid deployment issues
return NextResponse.next();
});
export const config = {
matcher: [
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
};