diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 910616b..198ab90 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -33,11 +33,16 @@ function isBanInfo(detail: unknown): detail is BanInfo { client.interceptors.response.use( (response) => response, (error: AxiosError<{ detail: string | BanInfo }>) => { - // Unauthorized - redirect to login + // Unauthorized - redirect to login (but not for auth endpoints) if (error.response?.status === 401) { - localStorage.removeItem('token') - localStorage.removeItem('user') - window.location.href = '/login' + const url = error.config?.url || '' + const isAuthEndpoint = url.includes('/auth/login') || url.includes('/auth/register') || url.includes('/auth/2fa') + + if (!isAuthEndpoint) { + localStorage.removeItem('token') + localStorage.removeItem('user') + window.location.href = '/login' + } } // Forbidden - check if user is banned