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 <cursoragent@cursor.com>
This commit is contained in:
4Ventures
2026-10-05 16:27:14 +02:00
parent bb5f721b38
commit 1f9bc38af0

View File

@@ -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;