import axios from "axios"; let currentAuthorizationInterceptorID = null; const http = axios.create({ baseURL: window.location.origin + "/api", timeout: 2000, }); function addBearerTokenInterceptor(token) { currentAuthorizationInterceptorID = http.interceptors.request.use((config) => { config.headers.Authorization = `Bearer ${token}`; return config; }, (err) => { console.error(err); }); } function removeBearerTokenInterceptor() { http.interceptors.request.eject(currentAuthorizationInterceptorID); } export { http, addBearerTokenInterceptor, removeBearerTokenInterceptor };