import { NextRequest, NextResponse } from 'next/server'; export function middleware(req: NextRequest) { const url = req.nextUrl.clone(); const path = url.pathname; if ( path.startsWith('/customer-dashboard') || path.startsWith('/corporate-dashboard') ) { const token = req.cookies.get( `${path.includes('customer') ? 'bonus' : 'corporate'}__token`, ); if (!token) { url.pathname = '/login'; return NextResponse.redirect(url); } } return NextResponse.next(); } export const config = { matcher: ['/customer-dashboard/:path*', '/corporate-dashboard/:path*'], };