import { NextResponse } from 'next/server'; import type { NextRequest } from 'next/server'; export function middleware(request: NextRequest) { // Public portal routes are generally open // Only protect specific routes if needed const protectedRoutes: string[] = []; // Add protected routes here if needed const isProtectedRoute = protectedRoutes.some((route) => request.nextUrl.pathname.startsWith(route)); if (isProtectedRoute) { const token = request.cookies.get('auth_token') || request.headers.get('authorization'); if (!token) { const loginUrl = new URL('/login', request.url); loginUrl.searchParams.set('redirect', request.nextUrl.pathname); return NextResponse.redirect(loginUrl); } } return NextResponse.next(); } export const config = { matcher: [], // Add protected routes here if needed };