Files
sexy/proxy.ts
T
valknarandClaude Sonnet 5 db507bfe3b
CI / Build and push image (push) Successful in 1m3s
CI / Static checks (push) Successful in 1m7s
Add web app manifest, bump version to 0.1.1
manifest.ts uses icon.svg and the app's palette for background/theme
color. Excluded /manifest.webmanifest from the auth gate in proxy.ts,
same as icon.svg/favicon.ico - it must be publicly fetchable regardless
of login state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W8WkFF5ppURBAB918593Eb
2026-08-25 17:02:19 +02:00

29 lines
902 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { SESSION_COOKIE_NAME, verifySessionToken } from "@/lib/auth/session";
export default async function proxy(req: NextRequest) {
const { pathname } = req.nextUrl;
const isAuthenticated = await verifySessionToken(req.cookies.get(SESSION_COOKIE_NAME)?.value);
if (isAuthenticated) {
if (pathname === "/login") {
return NextResponse.redirect(new URL("/", req.url));
}
return NextResponse.next();
}
if (pathname.startsWith("/api/")) {
return NextResponse.json({ error: "unauthorized" }, { status: 401 });
}
const loginUrl = new URL("/login", req.url);
loginUrl.searchParams.set("from", pathname);
return NextResponse.redirect(loginUrl);
}
export const config = {
matcher: [
"/((?!_next/static|_next/image|favicon.ico|icon.svg|manifest.webmanifest|login|api/auth/login|api/health).*)",
],
};