Skip to content

Commit 75eb711

Browse files
committed
fix: prevent unnecessary redirects to login on auth pages and during user verification checks
1 parent 21acd12 commit 75eb711

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

frontend/src/lib/api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ api.interceptors.response.use(
99
(res) => res,
1010
(err) => {
1111
if (err.response?.status === 401) {
12-
window.location.href = '/login'
12+
const url = err.config?.url || ''
13+
const path = window.location.pathname
14+
// Don't redirect if already on auth pages or if it's a /me check
15+
const isAuthPage = path === '/login' || path === '/register' || path === '/reset-password'
16+
const isMeCheck = url.includes('/auth/me')
17+
if (!isAuthPage && !isMeCheck) {
18+
window.location.href = '/login'
19+
}
1320
}
1421
return Promise.reject(err)
1522
}

0 commit comments

Comments
 (0)