Fixed front API conf broken in previous commit
This commit is contained in:
@@ -1,16 +1,24 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
|
import keycloak from "./keycloak";
|
||||||
|
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
// backend listens on 8081 and controllers are mounted at root (no /api prefix)
|
// backend listens on 8081 and controllers are mounted at root (no /api prefix)
|
||||||
baseURL: "http://localhost:8081",
|
baseURL: "http://localhost:8081",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Simple interceptor to ensure headers object exists; actual token should be set via setAuthToken()
|
// Simple interceptor to ensure headers object exists; actual token should be set via setAuthToken()
|
||||||
api.interceptors.request.use((config) => {
|
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;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user