From 8afa3c401f5899d8c2c6609052fa4750ff86a389 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Fri, 3 Apr 2026 07:05:20 +0900 Subject: [PATCH] fix: wait for auth refresh check before redirecting to login The $: reactive statement was firing before onMount's tryRefresh() completed, immediately redirecting to /login on every page refresh. Added authChecked flag to gate the redirect logic. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/routes/+layout.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 46db0ab..7bffba7 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -8,15 +8,17 @@ import '../app.css'; const PUBLIC_PATHS = ['/login', '/setup']; + let authChecked = false; onMount(async () => { if (!$isAuthenticated) { await tryRefresh(); } + authChecked = true; }); $: { - if (browser && !$isAuthenticated && !PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))) { + if (browser && authChecked && !$isAuthenticated && !PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))) { goto('/login'); } } @@ -32,7 +34,11 @@ -{#if $isAuthenticated || PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))} +{#if !authChecked} +
+

로딩 중...

+
+{:else if $isAuthenticated || PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))} {/if}