diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index b6c4304..422c43e 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -26,7 +26,16 @@ api.interceptors.response.use( async (error) => { const originalRequest = error.config; - if (error.response?.status === 401 && !originalRequest._retry) { + // Auth endpoints handle their own 401s (e.g. wrong credentials on the login + // form). Refreshing/redirecting here would reload the page and discard the + // error toast the caller is about to show. + const requestUrl: string = originalRequest?.url || ''; + const isAuthEndpoint = + requestUrl.includes('/auth/login') || + requestUrl.includes('/auth/register') || + requestUrl.includes('/auth/refresh'); + + if (error.response?.status === 401 && !originalRequest._retry && !isAuthEndpoint) { originalRequest._retry = true; try {