import { NextResponse, type NextRequest } from "next/server"; // Presence-only check: the API validates the signed cookie on every call. export function proxy(req: NextRequest) { const { pathname } = req.nextUrl; if (pathname.startsWith("/login") || pathname.startsWith("/api") || pathname.startsWith("/_next") || pathname === "/favicon.ico") { return NextResponse.next(); } if (!req.cookies.get("ktrade_session")) { const url = req.nextUrl.clone(); url.pathname = "/login"; url.searchParams.set("next", pathname); return NextResponse.redirect(url); } return NextResponse.next(); } export const config = { matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"] };