Initial commit with Email Import Wizard and Task Processor updates
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import axios from 'axios';
|
||||
import { getAccessToken } from '../auth/oidc';
|
||||
import { triggerLoginRedirect } from '../auth/sessionRedirect';
|
||||
import { getEnv } from '../utils/env';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: getEnv('VITE_API_URL') || '',
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
api.interceptors.request.use(async (config) => {
|
||||
const token = await getAccessToken();
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
async (error) => {
|
||||
if (error.response?.status === 401) {
|
||||
await triggerLoginRedirect();
|
||||
}
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
export default api;
|
||||
Reference in New Issue
Block a user