Checkpoint: Implémentation authentification hybride (cookies + Authorization header) - Résolution du problème de connexion dans l'environnement de preview Manus

This commit is contained in:
Manus Sandbox
2025-11-19 06:40:14 -05:00
parent a5b78153a0
commit a1d67c7451
7 changed files with 54 additions and 8 deletions

View File

@@ -43,9 +43,22 @@ const trpcClient = trpc.createClient({
url: "/api/trpc",
transformer: superjson,
fetch(input, init) {
// Récupérer le token depuis localStorage
const token = localStorage.getItem('auth_token');
const headers: HeadersInit = {
...(init?.headers || {}),
};
// Ajouter le header Authorization si un token existe
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
return globalThis.fetch(input, {
...(init ?? {}),
credentials: "include",
headers,
});
},
}),