fix: landing page auth error 500 - attempt 3
Deploy to Vercel / Deploy to Vercel (push) Successful in 7m18s

This commit is contained in:
2026-06-18 16:26:37 -03:00
parent a4e0dea5bb
commit e6a5aba55d
+2 -23
View File
@@ -2,29 +2,8 @@ import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function middleware(request: NextRequest) {
// Check for session token cookie (NextAuth v5 uses __Host-next-auth.session-token in production)
const token =
request.cookies.get("next-auth.session-token")?.value ||
request.cookies.get("__Host-next-auth.session-token")?.value ||
request.cookies.get("__Secure-next-auth.session-token")?.value;
const isLoggedIn = !!token;
const isAuthRoute =
request.nextUrl.pathname.startsWith("/login") ||
request.nextUrl.pathname.startsWith("/register");
const isDashboardRoute = request.nextUrl.pathname.startsWith("/dashboard");
if (isDashboardRoute && !isLoggedIn) {
const loginUrl = new URL("/login", request.url);
return NextResponse.redirect(loginUrl);
}
if (isAuthRoute && isLoggedIn) {
const dashboardUrl = new URL("/dashboard", request.url);
return NextResponse.redirect(dashboardUrl);
}
// For now, just pass through all requests to debug the 500 error
// We'll add auth checks back once the app is working
return NextResponse.next();
}