diff --git a/apps/admin/src/stores/useAuthStore.ts b/apps/admin/src/stores/useAuthStore.ts index 7b319496..a6b1cf94 100644 --- a/apps/admin/src/stores/useAuthStore.ts +++ b/apps/admin/src/stores/useAuthStore.ts @@ -43,7 +43,10 @@ export const useAuthStore = defineStore('auth', () => { function handleUnauthorized() { clearState() - isInitialized.value = false + // Do NOT reset isInitialized — the full page reload (below) resets all JS state. + // Resetting it here causes a race condition: the async 401 interceptor fires + // after doInitialize() sets isInitialized=true, putting the app back into + // a loading state that never resolves. if (typeof window !== 'undefined') { const publicPaths = ['/login', '/forgot-password', '/reset-password', '/verify-email-change'] diff --git a/apps/app/src/stores/useAuthStore.ts b/apps/app/src/stores/useAuthStore.ts index 78bb1af2..151f8869 100644 --- a/apps/app/src/stores/useAuthStore.ts +++ b/apps/app/src/stores/useAuthStore.ts @@ -60,7 +60,10 @@ export const useAuthStore = defineStore('auth', () => { function handleUnauthorized() { clearState() - isInitialized.value = false + // Do NOT reset isInitialized — the full page reload (below) resets all JS state. + // Resetting it here causes a race condition: the async 401 interceptor fires + // after doInitialize() sets isInitialized=true, putting the app back into + // a loading state that never resolves. if (typeof window !== 'undefined' && window.location.pathname !== '/login') { window.location.href = '/login' diff --git a/apps/portal/src/stores/useAuthStore.ts b/apps/portal/src/stores/useAuthStore.ts index 4287b97f..e659716c 100644 --- a/apps/portal/src/stores/useAuthStore.ts +++ b/apps/portal/src/stores/useAuthStore.ts @@ -25,7 +25,10 @@ export const useAuthStore = defineStore('auth', () => { function handleUnauthorized() { clearState() - isInitialized.value = false + // Do NOT reset isInitialized — the full page reload (below) resets all JS state. + // Resetting it here causes a race condition: the async 401 interceptor fires + // after doInitialize() sets isInitialized=true, putting the app back into + // a loading state that never resolves. if (typeof window !== 'undefined') { const path = window.location.pathname