diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index f5d5849..fa95c22 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -46,8 +46,14 @@ async function request( }); if (res.status === 401) { - await fetch("/api/auth/logout", { method: "POST" }).catch(() => {}); - if (typeof window !== "undefined") window.location.replace("/login"); + // Don't logout/redirect from the login page itself — that would loop. + if ( + typeof window !== "undefined" && + !window.location.pathname.startsWith("/login") + ) { + await fetch("/api/auth/logout", { method: "POST" }).catch(() => {}); + window.location.replace("/login"); + } throw new ApiError(401, null); }