后端代理地址改用配置文件

This commit is contained in:
不做码农 2022-09-29 21:59:37 +08:00
parent ea8258ce5f
commit a6551f61a1
2 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# 开发环境配置
ENV = 'development'
VITE_APP_API_HOST = 'http://localhost:8888'
# 开发环境
VITE_APP_BASE_API = '/dev-api'

View File

@ -51,12 +51,12 @@ export default defineConfig(({ mode, command }) => {
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: 'http://localhost:8888',
target: env.VITE_APP_API_HOST,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dev-api/, '')
},
'/msghub': {
target: 'http://localhost:8888',
target: env.VITE_APP_API_HOST,
ws: true,
rewrite: (path) => path.replace(/^\/msgHub/, '')
}