import { NextResponse } from 'next/server'; import type { NextRequest } from 'next/server'; export function proxy(request: NextRequest) { const token = request.cookies.get('auth_token')?.value; const path = request.nextUrl.pathname; // Protect /admin routes if (path.startsWith('/admin')) { if (token !== 'admin') { return NextResponse.redirect(new URL('/login', request.url)); } } // Protect /dashboard routes if (path.startsWith('/dashboard')) { if (!token) { return NextResponse.redirect(new URL('/login', request.url)); } } // Protect /onboarding route if (path.startsWith('/onboarding')) { if (!token) { return NextResponse.redirect(new URL('/login', request.url)); } } return NextResponse.next(); } export const config = { matcher: ['/dashboard/:path*', '/admin/:path*', '/onboarding/:path*', '/onboarding'] };