Add proxy.ts

main
Deardo Satria 2 weeks ago
parent 119c55bf67
commit bcfdc5c27a

@ -0,0 +1,15 @@
import { NextResponse, type NextRequest } from "next/server";
import { getSessionCookie } from "better-auth/cookies";
export function proxy(request: NextRequest) {
// Only checks that the cookie exists; getCurrentUser() still validates it.
if (!getSessionCookie(request)) {
return NextResponse.redirect(new URL("/login", request.url));
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!api|login|_next/static|_next/image|.*\\..*).*)"],
};
Loading…
Cancel
Save