前端单独打包接口地址困扰
duyaTech opened this issue · comments
您好,我希望能够把前端代码单独编译打包到nginx上,但是请求地址一直500报错,我注意到app文件夹中有vite.config.js,这里面配置了代理转发
server: { proxy: { "/api": { target: "http://localhost:8094", changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ""), ws: true, }, "/v1": { target: "http://localhost:8094", changeOrigin: true, } } }
我尝试修改了target为线上通过容器安装且能正常请求的后端地址,可是一直不生效,浏览器中的请求header仍然指向localhost:5173(我本地项目前端运行的地址),请教该如何修改。
vite里面是开发环境的mock server
.env
你为啥要用deeptrain模式。。。
VITE_USE_DEEPTRAIN=false
这个是不是就不通deeptrain模式啊
是 或者直接删了
.env.deeptrain 模式就是官网, 我意思是让你在打包的时候配置环境变量 ,或者新建一个 .env 文件配置环境,没让你复制 .env.deeptrain ...
搞定了!谢谢哈哈哈
OK