From 4de59ce6904784131540f5c797e19aad367f30e0 Mon Sep 17 00:00:00 2001 From: Kevin Cantrell Date: Tue, 7 Apr 2026 01:00:15 +0900 Subject: [PATCH] guarding the reset against making random requests kicking the user out --- src/routes/+layout.server.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 1df497e8..863b00f9 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -3,14 +3,18 @@ import type { LayoutServerLoad } from './$types'; export const load: LayoutServerLoad = async ({ locals, fetch }) => { -const apiServiceInstance = new ApiService({ - fetchFn: fetch, - authToken: locals.jwtString ?? null - }); +let profile; - const profile = await apiServiceInstance.getUserProfile().catch((error) => { - console.error('Failed to fetch authenticated user:', error); - }); + if (locals.jwtString) { + const apiServiceInstance = new ApiService({ + fetchFn: fetch, + authToken: locals.jwtString + }); + + profile = await apiServiceInstance.getUserProfile().catch((error) => { + console.error('Failed to fetch authenticated user:', error); + }); + } return { session: locals.jwt ?? null,