Compare commits
No commits in common. "53049d1c4d8eec7a1942f3bbc5078472f449f51e" and "0537378d82d5483fe75f63632cbc96f9a8ffdbd3" have entirely different histories.
53049d1c4d
...
0537378d82
1 changed files with 0 additions and 9 deletions
|
|
@ -20,15 +20,6 @@ async function apiFetch(path, opts = {}) {
|
||||||
headers: { 'Content-Type': 'application/json', ...(opts.headers || {}) },
|
headers: { 'Content-Type': 'application/json', ...(opts.headers || {}) },
|
||||||
...opts,
|
...opts,
|
||||||
});
|
});
|
||||||
// 401 from any API call means there's no live session. Bounce to the
|
|
||||||
// login screen instead of leaving the app in a half-loaded state.
|
|
||||||
// While AUTH_ENABLED=false the server returns a synthetic /auth/me with
|
|
||||||
// 200 so this branch never fires; flipping AUTH_ENABLED=true is what
|
|
||||||
// activates the redirect end-to-end.
|
|
||||||
if (res.status === 401 && !location.pathname.endsWith('/login.html')) {
|
|
||||||
location.replace('/login.html');
|
|
||||||
throw new Error('Unauthenticated — redirecting to login');
|
|
||||||
}
|
|
||||||
if (!res.ok) throw new Error(res.status + ' ' + res.statusText);
|
if (!res.ok) throw new Error(res.status + ' ' + res.statusText);
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue