Session 6.3
This commit is contained in:
@@ -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).*)"],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user