diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 95dabb4..76ed229 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -23,6 +23,10 @@ export interface CategoryConfig { 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}`)