Fix 401 redirect loop on login page
The 401 handler was redirecting to /login unconditionally, causing an infinite reload loop when useTheme fired unauthenticated API calls on the login page itself. Now only redirects if not already on /login. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,8 +58,9 @@ async function request<T>(
|
||||
// Global 401 handler — expired or invalid token
|
||||
if (response.status === 401) {
|
||||
localStorage.removeItem("token");
|
||||
window.location.href = "/login";
|
||||
// Throw so callers don't try to process the response
|
||||
if (window.location.pathname !== "/login") {
|
||||
window.location.href = "/login";
|
||||
}
|
||||
throw new ApiError(401, "Session expired");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user