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:
co-authored by
Claude Sonnet 4.6
parent
75b7ae6062
commit
05d79d3d21
@@ -58,8 +58,9 @@ async function request<T>(
|
|||||||
// Global 401 handler — expired or invalid token
|
// Global 401 handler — expired or invalid token
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
localStorage.removeItem("token");
|
localStorage.removeItem("token");
|
||||||
window.location.href = "/login";
|
if (window.location.pathname !== "/login") {
|
||||||
// Throw so callers don't try to process the response
|
window.location.href = "/login";
|
||||||
|
}
|
||||||
throw new ApiError(401, "Session expired");
|
throw new ApiError(401, "Session expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user