Fixed front API conf broken in previous commit

This commit is contained in:
Alexis Leboeuf
2026-01-08 14:57:41 +01:00
parent b82a32d0eb
commit 2818bdae8a

View File

@@ -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;
});