From 2818bdae8ae271e3ec77fdc7af7469c64734634b Mon Sep 17 00:00:00 2001 From: Alexis Leboeuf Date: Thu, 8 Jan 2026 14:57:41 +0100 Subject: [PATCH] Fixed front API conf broken in previous commit --- front_end/src/api.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/front_end/src/api.ts b/front_end/src/api.ts index 4d68e7b..2853924 100644 --- a/front_end/src/api.ts +++ b/front_end/src/api.ts @@ -1,16 +1,24 @@ import axios from "axios"; +import keycloak from "./keycloak"; + + const api = axios.create({ // backend listens on 8081 and controllers are mounted at root (no /api prefix) baseURL: "http://localhost:8081", headers: { "Content-Type": "application/json", }, + withCredentials: true, }); // Simple interceptor to ensure headers object exists; actual token should be set via setAuthToken() api.interceptors.request.use((config) => { - if (!config.headers) config.headers = {}; + if (keycloak?.token) { + // eslint-disable-next-line no-param-reassign + config.headers.Authorization = `Bearer ${keycloak.token}`; + console.log(config.headers.Authorization); + } return config; });