diff --git a/frontend/src/hooks.client.ts b/frontend/src/hooks.client.ts index 5160b2bd3..30e638bd0 100644 --- a/frontend/src/hooks.client.ts +++ b/frontend/src/hooks.client.ts @@ -63,11 +63,18 @@ function shouldTryAutoReload(updateDetected: boolean): boolean { */ handleFetch(async ({ fetch, args }) => { const response = await traceFetch(() => fetch(...args)); + if (response.status === 401 && location.pathname !== '/login') { throw redirect(307, '/logout'); } + + if (response.status >= 500) { + throw new Error(`Unexpected response: ${response.statusText} (${response.status}). URL: ${response.url}.`); + } + if (response.headers.get('lexbox-refresh-jwt') == 'true') { await invalidate(USER_LOAD_KEY); } + return response; });