From e17f29552c0dfbe09a9bbfcc9c914535ad923be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Krzeslak?= Date: Thu, 22 Oct 2026 16:56:13 +0200 Subject: [PATCH] fix(pages): fix session preservation on unauthenticated route --- src/pages/root.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pages/root.tsx b/src/pages/root.tsx index b0ea02f0..4aacd258 100644 --- a/src/pages/root.tsx +++ b/src/pages/root.tsx @@ -57,19 +57,21 @@ export const root = new Elysia().use(userService).get( }); user = { id: newUserId }; - if (!auth) { + + // Use existing cookie if it exists, otherwise set a new one + if (auth) { + auth.set({ + value: accessToken, + httpOnly: true, + secure: !HTTP_ALLOWED, + maxAge: 24 * 60 * 60, + sameSite: "strict", + }); + } else { return { message: "No auth cookie, perhaps your browser is blocking cookies.", }; } - - auth.set({ - value: accessToken, - httpOnly: true, - secure: !HTTP_ALLOWED, - maxAge: 24 * 60 * 60, - sameSite: "strict", - }); } } else if (auth?.value) { user = await jwt.verify(auth.value);