Authentication updates

This commit is contained in:
Jack Mechem 2026-03-28 16:01:45 -07:00
parent 98b1daa7d3
commit 3015c98246
15 changed files with 657 additions and 165 deletions

25
proxy.ts Normal file
View file

@ -0,0 +1,25 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function proxy(req: NextRequest) {
const token = req.cookies.get("token")?.value;
const { pathname } = req.nextUrl;
// always allow login page and auth api routes
if (pathname.startsWith("/auth") || pathname.startsWith("/api/auth")) {
return NextResponse.next();
}
// no token — redirect to login
if (!token) {
const loginUrl = new URL("/auth", req.url);
loginUrl.searchParams.set("callbackUrl", pathname);
return NextResponse.redirect(loginUrl);
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};