Skip to content

Commit 1c084b5

Browse files
committed
fix login loop
1 parent d936a52 commit 1c084b5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

frontend/src/services/api.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ const api = axios.create({
1212
api.interceptors.response.use(
1313
(response) => response,
1414
(error) => {
15-
if (error.response?.status === 401) {
16-
window.location.href = '/login';
15+
// Don't redirect on 401 for auth status checks - that's expected when not logged in
16+
const isAuthStatusCheck = error.config?.url?.includes('/auth/status');
17+
18+
if (error.response?.status === 401 && !isAuthStatusCheck) {
19+
// Only redirect if we're not already on the login page
20+
if (window.location.pathname !== '/login') {
21+
window.location.href = '/login';
22+
}
1723
}
1824
return Promise.reject(error);
1925
}

0 commit comments

Comments
 (0)