diff --git a/it0-web-admin/src/infrastructure/api/api-client.ts b/it0-web-admin/src/infrastructure/api/api-client.ts index 1b2cc14..2e14145 100644 --- a/it0-web-admin/src/infrastructure/api/api-client.ts +++ b/it0-web-admin/src/infrastructure/api/api-client.ts @@ -42,6 +42,13 @@ export async function apiClient(endpoint: string, options: RequestOptions = { }); if (!response.ok) { + if (response.status === 401 && typeof window !== 'undefined') { + localStorage.removeItem('access_token'); + localStorage.removeItem('refresh_token'); + localStorage.removeItem('current_tenant'); + window.location.href = '/login'; + throw new Error('Session expired'); + } const errorData = await response.json().catch(() => null); const message = errorData?.message || `${response.status} ${response.statusText}`; throw new Error(message);