Описание изменений
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user