refactor: Replace axios with api module in ASNs, Domains, IPRanges managers, and S3MetaBar for consistent API interaction and improved code maintainability
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 5m5s

This commit is contained in:
2025-08-11 16:46:27 +07:00
parent 415f05f6aa
commit f1b84a761e
6 changed files with 97 additions and 20 deletions
+33
View File
@@ -0,0 +1,33 @@
import axios from 'axios';
// Базовый axios-клиент для всего приложения
const api = axios.create({
baseURL: '/api',
timeout: 10000,
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
});
// Авто-ретрай для идемпотентных GET: до 2 попыток с экспоненциальной задержкой
api.interceptors.response.use(
(response) => response,
async (error) => {
const config = error?.config || {};
const isGet = String(config.method || 'get').toLowerCase() === 'get';
const status = error?.response?.status;
const retriable = !error.response || (status >= 500 && status !== 501);
config.__retryCount = config.__retryCount || 0;
if (isGet && retriable && config.__retryCount < 2) {
config.__retryCount += 1;
const delay = 300 * Math.pow(2, config.__retryCount - 1);
await new Promise((r) => setTimeout(r, delay));
return api(config);
}
return Promise.reject(error);
}
);
export default api;