Session 6.3

This commit is contained in:
2026-04-10 21:56:31 +02:00
parent f20d5f09ae
commit 94bfd25553
24 changed files with 2398 additions and 104 deletions

View File

@@ -6,22 +6,23 @@ import { routing } from "@/i18n/routing";
const intlMiddleware = createIntlMiddleware(routing);
const publicPaths = ["/login", "/api/auth"];
const publicPaths = ["/login", "/register", "/api/auth", "/api/register"];
function isPublicPath(pathname: string): boolean {
// Strip locale prefix for comparison
const stripped = pathname.replace(/^\/(de|fr|it|en)/, "") || "/";
return (
publicPaths.some((p) => stripped === p || stripped.startsWith(`${p}/`)) ||
pathname.startsWith("/api/auth")
pathname.startsWith("/api/auth") ||
pathname.startsWith("/api/register")
);
}
export default async function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
// NextAuth API routes pass through directly
if (pathname.startsWith("/api/auth")) {
// NextAuth API routes and register API pass through directly
if (pathname.startsWith("/api/auth") || pathname.startsWith("/api/register")) {
return NextResponse.next();
}
@@ -39,5 +40,5 @@ export default async function middleware(request: NextRequest) {
}
export const config = {
matcher: ["/((?!_next|favicon.ico|api).*)" ],
matcher: ["/((?!_next|favicon.ico|api).*)"],
};