修复管理系统bug

main
wang 1 month ago
parent 10643c1a2f
commit 9fc8cd5a74

File diff suppressed because one or more lines are too long

@ -243,7 +243,6 @@ export default {
const response = await axios.get('/api/test/admin_status', {
withCredentials: true,
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Authorization': token ? `Bearer ${token}` : ''
}
})

@ -3,17 +3,19 @@ import App from './App.vue'
import router from './router'
import axios from 'axios'
// 配置axios默认URL使用当前主机名而不是硬编码的localhost
const currentHost = window.location.hostname
axios.defaults.baseURL = process.env.NODE_ENV === 'production'
? ''
: `http://${currentHost}:5000`
// 配置axios默认URL
// 使用相对路径让Vue代理处理API请求
axios.defaults.baseURL = ''
// 打印当前使用的baseURL便于调试
console.log('使用相对路径让Vue代理处理API请求')
// 确保axios请求发送凭证(cookies)
axios.defaults.withCredentials = true
// 设置默认头部
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
// 添加请求拦截器自动添加Authorization头和检查请求数据
axios.interceptors.request.use(config => {

Loading…
Cancel
Save