Описание изменений

This commit is contained in:
2025-03-14 12:02:59 +03:00
parent 681343d851
commit 4e3fc30cb5
23 changed files with 1564 additions and 1326 deletions

View File

@@ -1,26 +1,28 @@
import axios from 'axios';
// Создаем экземпляр axios с базовым URL
const api = axios.create({
baseURL: 'http://localhost:8000',
withCredentials: true, // Важно для передачи куков между запросами
const instance = axios.create({
baseURL: '/',
withCredentials: true,
headers: {
'Content-Type': 'application/json',
},
});
// Удаляем перехватчик, который добавлял заголовок Authorization из localStorage
// api.interceptors.request.use(
// (config) => {
// const address = localStorage.getItem('walletAddress');
// if (address) {
// config.headers.Authorization = `Bearer ${address}`;
// }
// return config;
// },
// (error) => {
// return Promise.reject(error);
// }
// );
// Добавляем перехватчик для добавления заголовка авторизации
instance.interceptors.request.use(
(config) => {
console.log('Axios interceptor running');
const address = localStorage.getItem('walletAddress');
if (address) {
console.log('Adding Authorization header in interceptor:', `Bearer ${address}`);
config.headers.Authorization = `Bearer ${address}`;
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
export default api;
export default instance;