import axios from 'axios';
|
if (import.meta.env.VITE_APP_ENV === 'dev') {
|
// 跨域请求
|
axios.defaults.baseURL = 'http://110.40.173.177:8005/';
|
} else {
|
axios.defaults.baseURL = location.protocol + '//' + location.hostname + ':8005/';
|
}
|
axios.defaults.baseURL = 'http://110.40.173.177:8005/';
|
// 添加请求拦截器
|
axios.interceptors.request.use(function (config) {
|
// 在发送请求之前做些什么
|
return config;
|
}, function (error) {
|
// 对请求错误做些什么
|
return Promise.reject(error);
|
});
|
|
// 添加响应拦截器
|
axios.interceptors.response.use(function (response) {
|
// 对响应数据做点什么
|
return response;
|
}, function (error) {
|
return Promise.reject(error);
|
});
|
|
export default axios;
|