-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmiddleware.ts
More file actions
53 lines (45 loc) · 1.48 KB
/
middleware.ts
File metadata and controls
53 lines (45 loc) · 1.48 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
41
42
43
44
45
46
47
48
49
50
51
52
53
// middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
// Public routes that don't require authentication
const publicPaths = [
"/",
"/login",
"/api/auth",
"/forgot-password",
"/reset-password",
"/verify",
"/set-password",
"/resend-verification",
];
export async function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
// Allow public routes
if (publicPaths.some((path) => pathname.startsWith(path))) {
return NextResponse.next();
}
// For now, let all authenticated routes pass through
// The frontend will handle authentication checks using localStorage
// This can be enhanced later with proper session management
// Let the frontend handle login page redirects
// The frontend will check if user is authenticated and redirect accordingly
// For dashboard routes, let the frontend handle permission checks
// The frontend will use the user's position access permissions to show/hide navigation
if (pathname.startsWith("/dashboard")) {
return NextResponse.next();
}
// All good for other authenticated routes
return NextResponse.next();
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
* - public folder
*/
"/((?!_next/static|_next/image|favicon.ico|public/).*)",
],
};