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)