From 05d79d3d21083b5675b143e4dc9f43b7188b3034 Mon Sep 17 00:00:00 2001 From: curo1305 Date: Sat, 18 Apr 2026 21:16:45 +0200 Subject: [PATCH] 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 --- frontend/src/api/client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index c649504..1cf1144 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -58,8 +58,9 @@ async function request( // 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"); }