From 6cd15067cb6a2774d979e83a7d3b59c7b33031ec Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Wed, 25 Sep 2024 20:53:50 +0100 Subject: [PATCH] Fix error on corrupt session logout --- packages/frontpage/middleware.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontpage/middleware.ts b/packages/frontpage/middleware.ts index 8278cc83..af322c84 100644 --- a/packages/frontpage/middleware.ts +++ b/packages/frontpage/middleware.ts @@ -17,7 +17,7 @@ import { signOut, } from "./lib/auth"; -export async function middleware(_request: NextRequest) { +export async function middleware(request: NextRequest) { const session = await getSession(); if (!session) { return NextResponse.next(); @@ -92,7 +92,7 @@ export async function middleware(_request: NextRequest) { // Logout and show error console.log("session corrupt, logging out", result); await signOut(); - const response = NextResponse.redirect("/login"); + const response = NextResponse.redirect(new URL("/login", request.url)); deleteAuthCookie(response.cookies); return response; }