trading-app/src/proxy.ts
David 27a358038a
Some checks failed
Tick / tick (push) Failing after 1s
Cagnotte V1: IA news-driven trading sim, sandbox, PEA tracking, PWA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:06:17 +01:00

16 lines
735 B
TypeScript

import { NextResponse, type NextRequest } from "next/server";
import { isValidSession, SESSION_COOKIE } from "@/lib/auth";
/** Toutes les pages demandent d'être connecté, sauf la connexion, les tâches planifiées et les fichiers de l'app. */
export async function proxy(request: NextRequest) {
if (await isValidSession(request.cookies.get(SESSION_COOKIE)?.value)) return NextResponse.next();
if (request.nextUrl.pathname.startsWith("/api/")) {
return NextResponse.json({ error: "Non connecté" }, { status: 401 });
}
return NextResponse.redirect(new URL("/login", request.url));
}
export const config = {
matcher: ["/((?!login|api/cron|manifest.webmanifest|sw.js|pwa-icon|apple-icon|icon|favicon.ico|_next).*)"],
};