fix alot of things

This commit is contained in:
NotII
2025-03-14 16:48:08 +00:00
parent c15e8119c7
commit 87a58a6736
17 changed files with 79 additions and 3102 deletions

View File

@@ -10,30 +10,19 @@ export async function middleware(req: NextRequest) {
}
try {
// Make sure we use a complete URL with protocol
// When running locally with integrated backend, we need to specify the full URL including protocol
const origin = req.nextUrl.origin;
const authEndpoint = new URL("/api/auth/me", origin).toString();
console.log("Verifying authentication with endpoint:", authEndpoint);
const res = await fetch(authEndpoint, {
method: "GET",
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/me`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
// Ensure we're not caching authentication checks
cache: 'no-store'
});
if (!res.ok) {
console.error(`Auth check failed with status: ${res.status}`);
return NextResponse.redirect(new URL("/auth/login", req.url));
}
} catch (error) {
console.error("Authentication validation failed:", error);
console.error("Error details:", error instanceof Error ? error.message : 'Unknown error');
return NextResponse.redirect(new URL("/auth/login", req.url));
}