fix: guard goto() with browser check to prevent SSR crash

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-03 06:47:48 +09:00
parent fce9124c28
commit a872dfc10f

View File

@@ -1,5 +1,6 @@
<script>
import { onMount } from 'svelte';
import { browser } from '$app/environment';
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { isAuthenticated, tryRefresh, logout } from '$lib/stores/auth';
@@ -15,7 +16,7 @@
});
$: {
if (!$isAuthenticated && !PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))) {
if (browser && !$isAuthenticated && !PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))) {
goto('/login');
}
}