From 7c8991d5ce91be7c36bcb6d78e250b35d8956ffe Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Sun, 12 Jul 2026 20:09:17 +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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 3ae9074..fa93d10 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -4,6 +4,10 @@ const BASE = '/twin-optimiser/api' async function request(path: string, opts?: RequestInit): Promise { const res = await fetch(BASE + path, { credentials: 'include', ...opts }) + if (res.status === 401) { + ;(window.top ?? window).location.href = '/login' + throw new Error('Unauthenticated') + } if (!res.ok) { const body = await res.json().catch(() => ({})) as { error?: string } throw new Error(body.error || `HTTP ${res.status}`)