SPB Git forge
1commits 1branches 0releases
189.0 KBsize
maindefault branch
4 h agolast push
Python 54.7% TypeScript 42.5% SQL 1.9%
702 B · 19 lines typescript
Raw Blame History
1import { NextResponse, type NextRequest } from "next/server";23// Presence-only check: the API validates the signed cookie on every call.4export function proxy(req: NextRequest) {5  const { pathname } = req.nextUrl;6  if (pathname.startsWith("/login") || pathname.startsWith("/api") || pathname.startsWith("/_next") || pathname === "/favicon.ico") {7    return NextResponse.next();8  }9  if (!req.cookies.get("ktrade_session")) {10    const url = req.nextUrl.clone();11    url.pathname = "/login";12    url.searchParams.set("next", pathname);13    return NextResponse.redirect(url);14  }15  return NextResponse.next();16}1718export const config = { matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"] };19