22 lines
602 B
JavaScript
22 lines
602 B
JavaScript
import axios from 'axios';
|
|
import { getRuntimeApplicationId, getRuntimeCompanyId } from '../utils/runtimeContext';
|
|
|
|
const apiClient = axios.create({
|
|
baseURL: '/',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
|
|
apiClient.interceptors.request.use((config) => {
|
|
const companyId = getRuntimeCompanyId();
|
|
const applicationId = getRuntimeApplicationId();
|
|
const headers = config.headers || {};
|
|
|
|
if (companyId) headers['x-company-id'] = companyId;
|
|
if (applicationId) headers['x-application-id'] = applicationId;
|
|
|
|
config.headers = headers;
|
|
return config;
|
|
});
|
|
|
|
export default apiClient;
|