PraxaLing / proxy.ts
Reubencf's picture
feat: full redesign — dark cinematic UI, interactive dialogues, Gemma 4 31B vision
dfa877e
import { NextResponse, type NextRequest } from "next/server";
import { SESSION_COOKIE } from "@/lib/auth/session";
const PROTECTED_PREFIXES = ["/practice", "/camera", "/profile", "/onboarding"];
export function proxy(req: NextRequest) {
const { pathname } = req.nextUrl;
if (!PROTECTED_PREFIXES.some((p) => pathname === p || pathname.startsWith(p + "/"))) {
return NextResponse.next();
}
const hasSession = Boolean(req.cookies.get(SESSION_COOKIE)?.value);
if (!hasSession) {
const url = req.nextUrl.clone();
url.pathname = "/";
url.searchParams.set("next", pathname);
return NextResponse.redirect(url);
}
return NextResponse.next();
}
export const config = {
matcher: ["/practice/:path*", "/camera/:path*", "/profile/:path*", "/onboarding/:path*"],
};