From f8847c0726baab5a03e79d584734e39dc0162175 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Sun, 12 Jul 2026 20:09:15 +0000 Subject: [PATCH] Redirect to login on mid-session 401 instead of silently failing Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/api.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 319d37d..778cbaa 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -7,6 +7,10 @@ async function req(method: string, path: string, body?: unknown): Promise headers: body ? { 'Content-Type': 'application/json' } : undefined, body: body ? JSON.stringify(body) : undefined, }) + if (res.status === 401) { + ;(window.top ?? window).location.href = '/login' + throw new Error('Unauthenticated') + } if (!res.ok) { const err = await res.json().catch(() => ({ error: res.statusText })) throw new Error((err as { error?: string }).error || res.statusText) @@ -36,6 +40,10 @@ export async function uploadAttachment( credentials: 'include', body: fd, }) + if (res.status === 401) { + ;(window.top ?? window).location.href = '/login' + throw new Error('Unauthenticated') + } if (!res.ok) { const err = await res.json().catch(() => ({ error: res.statusText })) throw new Error((err as { error?: string }).error || res.statusText)