From 1f9bc38af0db08e0888ff9319fa62697f6d7eb6f Mon Sep 17 00:00:00 2001 From: 4Ventures <4ventures@MacBook-Air-de-4Ventures.local> Date: Mon, 5 Oct 2026 16:27:14 +0200 Subject: [PATCH] fix: use getSession in middleware so login works offline of Kong Edge getUser() could not reach Auth, so a valid cookie still looked logged-out. Route on the local session cookie instead. Co-authored-by: Cursor --- src/middleware.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index bb34766..1d4c8d5 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -49,9 +49,12 @@ export async function middleware(req: NextRequest) { } ); + // Prefer local session from cookie. getUser() revalidates via Auth network and + // fails in this Edge runtime when Kong/hairpin is broken → endless login loop. const { - data: { user }, - } = await supabase.auth.getUser(); + data: { session }, + } = await supabase.auth.getSession(); + const user = session?.user ?? null; const url = req.nextUrl.clone(); const path = url.pathname;