import { NextResponse, type NextRequest } from 'next/server'; export function middleware(req: NextRequest) { // Route handlers and page components validate the actual session and admin role. if (req.cookies.has('__Secure-lumen.session_token') || req.cookies.has('lumen.session_token')) { return NextResponse.next(); } const login = req.nextUrl.clone(); login.pathname = '/login'; login.searchParams.set('next', req.nextUrl.pathname); return NextResponse.redirect(login); } export const config = { matcher: ['/admin/:path*', '/orders/:path*'], };