修复管理系统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', { const response = await axios.get('/api/test/admin_status', {
withCredentials: true, withCredentials: true,
headers: { headers: {
'X-Requested-With': 'XMLHttpRequest',
'Authorization': token ? `Bearer ${token}` : '' 'Authorization': token ? `Bearer ${token}` : ''
} }
}) })

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

Loading…
Cancel
Save