fix: preserve route on page refresh by removing timeout from background session check
When localStorage confirms auth, the background revalidation now uses store.checkSession() directly instead of the 8-second timeout wrapper. This prevents premature redirects to /login on slow networks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -179,14 +179,16 @@ router.beforeEach(async (to, _from, next) => {
|
||||
return
|
||||
}
|
||||
|
||||
// Protected routes: validate session if stale auth from localStorage (with timeout)
|
||||
// Protected routes: validate session if stale auth from localStorage
|
||||
if (store.needsSessionValidation()) {
|
||||
const valid = await checkSessionWithTimeout(store)
|
||||
if (!valid) {
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
// localStorage says we're authed — proceed immediately, revalidate in background.
|
||||
// No timeout wrapper here: a slow server shouldn't bounce the user to login.
|
||||
next()
|
||||
store.checkSession().then((valid) => {
|
||||
if (!valid) {
|
||||
router.replace('/login').catch(() => {})
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user