feat: 优化开发配置
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
# 接口前缀
|
|
||||||
VITE_APP_BASEAPI="/api-dev"
|
|
||||||
VITE_APP_URL="http://123.207.63.87:19001/api/app"
|
|
||||||
# VITE_APP_URL="http://localhost:19001/api/app"
|
|
||||||
VITE_APP_ENV_NAME = "dev"
|
VITE_APP_ENV_NAME = "dev"
|
||||||
|
|
||||||
|
# 接口前缀
|
||||||
|
VITE_APP_BASEAPI="/dev-api"
|
||||||
|
VITE_APP_URL="http://localhost:19001/api/app"
|
||||||
|
|
||||||
|
|
||||||
# ws/开发环境
|
# ws/开发环境
|
||||||
VITE_APP_BASE_WS = '/dev-ws'
|
VITE_APP_BASE_WS = '/dev-ws'
|
||||||
|
VITE_APP_BASE_URL_WS="http://localhost:19001/api/app"
|
||||||
#长连接
|
|
||||||
VITE_APP_BASE_URL_WS='http://localhost:19001/hub'
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
# 接口前缀
|
|
||||||
VITE_APP_BASEAPI="/prod-api"
|
|
||||||
VITE_APP_URL="http://123.207.63.87:19001/api/app"
|
|
||||||
VITE_APP_ENV_NAME = "pro"
|
VITE_APP_ENV_NAME = "pro"
|
||||||
|
|
||||||
# ws/开发环境
|
# 接口前缀
|
||||||
VITE_APP_BASE_WS = '/dev-ws'
|
VITE_APP_BASEAPI="/prod-api"
|
||||||
#长连接
|
VITE_APP_URL="http://ccnetcore.com:19001/api/app"
|
||||||
VITE_APP_BASE_URL_WS='http://localhost:19001/hub'
|
|
||||||
|
# ws
|
||||||
|
VITE_APP_BASE_WS = '/prod-ws'
|
||||||
|
VITE_APP_BASE_URL_WS="http://ccnetcore.com:19001/hub"
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
|
"prod": "vite --mode production",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -33,13 +33,32 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
[env.VITE_APP_BASEAPI]: {
|
[env.VITE_APP_BASEAPI]: {
|
||||||
target: env.VITE_APP_URL,
|
target: env.VITE_APP_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api-dev/, ""),
|
rewrite: (path) => path.replace(`${[env.VITE_APP_BASEAPI]}`, ""),
|
||||||
|
|
||||||
|
//查看真实代理url
|
||||||
|
// bypass(req, res, options) {
|
||||||
|
|
||||||
|
// const proxyUrl = options.target + options.rewrite(req.url);
|
||||||
|
// console.log(proxyUrl);
|
||||||
|
// req.headers['X-req-proxyURL'] = proxyUrl;
|
||||||
|
// res.setHeader('X-req-proxyURL', proxyUrl);
|
||||||
|
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
[env.VITE_APP_BASE_WS]: {
|
[env.VITE_APP_BASE_WS]: {
|
||||||
target: env.VITE_APP_BASE_URL_WS,
|
target: env.VITE_APP_BASE_URL_WS,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace(/^\/dev-ws/, ""),
|
rewrite: (p) => p.replace( `${[env.VITE_APP_BASE_WS]}`, ""),
|
||||||
ws: true,
|
ws: true,
|
||||||
|
//查看真实代理url
|
||||||
|
bypass(req, res, options) {
|
||||||
|
|
||||||
|
const proxyUrl = options.target + options.rewrite(req.url);
|
||||||
|
console.log(proxyUrl);
|
||||||
|
req.headers['X-req-proxyURL'] = proxyUrl;
|
||||||
|
res.setHeader('X-req-proxyURL', proxyUrl);
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user