import { NextRequest, NextResponse } from "next/server"; // Public marketing pages — no session required. Keep this in sync with // MARKETING_PATHS in components/ChromeSwitcher.tsx (that one picks page // chrome; this one decides whether to redirect at all). const PUBLIC_PATHS = new Set(["/", "/features", "/pricing", "/faq"]); // NOTE: this is a UX redirect only, not a security boundary — it just checks // a client-set cookie's presence. Real enforcement is server-side, in // drb-c2-core/app/internal/auth.py. See CLAUDE.md. export function middleware(request: NextRequest) { const session = request.cookies.get("drb_session"); const { pathname } = request.nextUrl; if (PUBLIC_PATHS.has(pathname)) { return NextResponse.next(); } if (pathname === "/login") { if (session) return NextResponse.redirect(new URL("/dashboard", request.url)); return NextResponse.next(); } if (!session) { return NextResponse.redirect(new URL("/login", request.url)); } return NextResponse.next(); } export const config = { matcher: ["/((?!_next/static|_next/image|favicon\\.ico).*)"], };