diff --git a/Yi.Bbs.Vue3/.env.development b/Yi.Bbs.Vue3/.env.development index 18bc139b..fa1e6cbf 100644 --- a/Yi.Bbs.Vue3/.env.development +++ b/Yi.Bbs.Vue3/.env.development @@ -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_BASEAPI="/dev-api" +VITE_APP_URL="http://localhost:19001/api/app" + + # ws/开发环境 VITE_APP_BASE_WS = '/dev-ws' - -#长连接 -VITE_APP_BASE_URL_WS='http://localhost:19001/hub' \ No newline at end of file +VITE_APP_BASE_URL_WS="http://localhost:19001/api/app" \ No newline at end of file diff --git a/Yi.Bbs.Vue3/.env.production b/Yi.Bbs.Vue3/.env.production index f8be2a0f..b69d6e43 100644 --- a/Yi.Bbs.Vue3/.env.production +++ b/Yi.Bbs.Vue3/.env.production @@ -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" -# ws/开发环境 -VITE_APP_BASE_WS = '/dev-ws' -#长连接 -VITE_APP_BASE_URL_WS='http://localhost:19001/hub' \ No newline at end of file +# 接口前缀 +VITE_APP_BASEAPI="/prod-api" +VITE_APP_URL="http://ccnetcore.com:19001/api/app" + +# ws +VITE_APP_BASE_WS = '/prod-ws' +VITE_APP_BASE_URL_WS="http://ccnetcore.com:19001/hub" \ No newline at end of file diff --git a/Yi.Bbs.Vue3/package.json b/Yi.Bbs.Vue3/package.json index 489e93b7..a4e325f4 100644 --- a/Yi.Bbs.Vue3/package.json +++ b/Yi.Bbs.Vue3/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "vite", "build": "vite build", + "prod": "vite --mode production", "preview": "vite preview" }, "dependencies": { diff --git a/Yi.Bbs.Vue3/vite.config.js b/Yi.Bbs.Vue3/vite.config.js index a4996fbe..a3a3a9bb 100644 --- a/Yi.Bbs.Vue3/vite.config.js +++ b/Yi.Bbs.Vue3/vite.config.js @@ -33,13 +33,32 @@ export default defineConfig(({ command, mode }) => { [env.VITE_APP_BASEAPI]: { target: env.VITE_APP_URL, 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]: { target: env.VITE_APP_BASE_URL_WS, changeOrigin: true, - rewrite: (p) => p.replace(/^\/dev-ws/, ""), + rewrite: (p) => p.replace( `${[env.VITE_APP_BASE_WS]}`, ""), 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); + + } }, }, },