-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
33 lines (27 loc) · 1003 Bytes
/
middleware.ts
File metadata and controls
33 lines (27 loc) · 1003 Bytes
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
// // middleware.ts
// import { NextResponse } from 'next/server'
// import type { NextRequest } from 'next/server'
// // Protected routes
// const protectedRoutes = ['/dashboard', '/setup'];
// export function middleware(request: NextRequest) {
// const pathname = request.nextUrl.pathname;
// const token = request.cookies.get('token')?.value;
// const isProtectedRoute = protectedRoutes.some(route => pathname.startsWith(route));
// if (isProtectedRoute && !token) {
// const url = new URL('/login', request.url);
// return NextResponse.redirect(url);
// }
// // If there's a token and user tries to access login/signup, redirect to dashboard
// if (token && (pathname === '/login' || pathname === '/signup')) {
// return NextResponse.redirect(new URL('/dashboard', request.url));
// }
// return NextResponse.next();
// }
// export const config = {
// matcher: [
// '/dashboard/:path*',
// '/setup/:path*',
// '/login',
// '/signup'
// ],
// };