Files
Stirling-PDF/frontend/src/core/services/apiClient.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
808 B
TypeScript
Raw Normal View History

import axios from 'axios';
import { handleHttpError } from '@app/services/httpErrorHandler';
import { setupApiInterceptors } from '@app/services/apiClientSetup';
2025-11-05 11:44:59 +00:00
import { getApiBaseUrl } from '@app/services/apiClientConfig';
// Create axios instance with default config
const apiClient = axios.create({
2025-11-05 11:44:59 +00:00
baseURL: getApiBaseUrl(),
responseType: 'json',
withCredentials: true,
});
// 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;