Bugfix/V2/remove-timeout-on-fetch (#4510)

Co-authored-by: Connor Yoh <[email protected]>
This commit is contained in:
ConnorYoh
2025-09-26 15:36:41 +01:00
committed by GitHub
co-authored by Connor Yoh
parent 0bdc6466ca
commit 7d44cc1a40
8 changed files with 286 additions and 317 deletions
+22
View File
@@ -0,0 +1,22 @@
// frontend/src/services/http.ts
import axios from 'axios';
import { handleHttpError } from './httpErrorHandler';
// Create axios instance with default config
const apiClient = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/', // Use env var or relative path (proxied by Vite in dev)
responseType: 'json',
});
// ---------- 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;