mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 12:28:48 +02:00
Skip 401 logout/redirect when already on the login page (FE-22)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,8 +46,14 @@ async function request<T>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 401) {
|
if (res.status === 401) {
|
||||||
|
// 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(() => {});
|
await fetch("/api/auth/logout", { method: "POST" }).catch(() => {});
|
||||||
if (typeof window !== "undefined") window.location.replace("/login");
|
window.location.replace("/login");
|
||||||
|
}
|
||||||
throw new ApiError(401, null);
|
throw new ApiError(401, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user