fixed push notifications and auth modified
CI/CD / Backend Unit Tests (push) Successful in 2m17s
CI/CD / Deploy (push) Successful in 2m26s

This commit is contained in:
2026-06-11 13:30:36 +02:00
parent 3afe5e2931
commit 7d7e641f5b
8 changed files with 72 additions and 9 deletions
+9
View File
@@ -6,6 +6,14 @@ function authHeader(token?: string) {
return token ? { Authorization: `Bearer ${token}` } : {};
}
let onUnauthorized: (() => void) | null = null;
// Called once from AuthProvider so api.tsx can trigger a logout/relogin
// when the backend rejects a request due to a missing/expired/invalid token.
export function setUnauthorizedHandler(handler: (() => void) | null) {
onUnauthorized = handler;
}
async function request<T>(
method: string,
path: string,
@@ -30,6 +38,7 @@ async function request<T>(
console.log('Failed URL:', res.url);
console.log('Status:', res.status);
console.log('Response:', errorText);
if (res.status === 401 && token) onUnauthorized?.();
throw new Error(errorText);
}
return res.json();