Commit 7b722871 by zhangxingmin

配置 test

parent ae900c2d
...@@ -5,4 +5,4 @@ VITE_APP_TITLE = 银盾中台系统 ...@@ -5,4 +5,4 @@ VITE_APP_TITLE = 银盾中台系统
VITE_APP_ENV = 'testelopment' VITE_APP_ENV = 'testelopment'
# 若依管理系统/开发环境 # 若依管理系统/开发环境
VITE_APP_BASE_API = 'http://139.224.145.34:9002' VITE_APP_BASE_API = /api
...@@ -13,20 +13,12 @@ export let isRelogin = { show: false } ...@@ -13,20 +13,12 @@ export let isRelogin = { show: false }
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 使用相对路径 /api,而不是完整URL // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: '/api', // 使用相对路径 baseURL: import.meta.env.VITE_APP_BASE_API || '/api', // 使用环境变量
timeout: 10000 timeout: 10000
}) })
// 创建axios实例
// const service = axios.create({
// // axios中请求配置有baseURL选项,表示请求URL公共部分
// baseURL: import.meta.env.VITE_APP_BASE_API,
// // 超时
// timeout: 10000
// })
// request拦截器 // request拦截器
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
......
...@@ -46,15 +46,15 @@ export default defineConfig(({ mode, command }) => { ...@@ -46,15 +46,15 @@ export default defineConfig(({ mode, command }) => {
host: true, host: true,
open: true, open: true,
proxy: { proxy: {
// https://cn.vitejs.dev/config/#server-proxy // 开发环境代理配置,与生产环境保持一致
'/dev-api': { '/api': {
target: baseUrl, target: 'http://139.224.145.34:9002', // 直接使用后端地址
changeOrigin: true, changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '') rewrite: (p) => p.replace(/^\/api/, '')
}, },
// springdoc proxy // springdoc proxy
'^/v3/api-docs/(.*)': { '^/v3/api-docs/(.*)': {
target: baseUrl, target: 'http://139.224.145.34:9002',
changeOrigin: true, changeOrigin: true,
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment