mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-18 20:04:17 +01:00
30 lines
874 B
TypeScript
30 lines
874 B
TypeScript
import axios from 'axios';
|
|
import { handleHttpError } from '@app/services/httpErrorHandler';
|
|
import { setupApiInterceptors } from '@app/services/apiClientSetup';
|
|
import { getApiBaseUrl } from '@app/services/apiClientConfig';
|
|
|
|
// Create axios instance with default config
|
|
const apiClient = axios.create({
|
|
baseURL: getApiBaseUrl(),
|
|
responseType: 'json',
|
|
withCredentials: true,
|
|
xsrfCookieName: 'XSRF-TOKEN',
|
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
});
|
|
|
|
// Setup interceptors (core does nothing, proprietary adds JWT auth)
|
|
setupApiInterceptors(apiClient);
|
|
|
|
// ---------- Install error interceptor ----------
|
|
apiClient.interceptors.response.use(
|
|
(response) => response,
|
|
async (error) => {
|
|
await handleHttpError(error); // Handle error (shows toast unless suppressed)
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
|
|
// ---------- Exports ----------
|
|
export default apiClient;
|