引入axios,配置代理,打包后失效 #366
Unanswered
tujsgithub
asked this question in
Q&A
Replies: 2 comments
-
proxy代理配置只在开发时生效,可参考我写的小demo,https://github.com/luckyLocas/electron-vite-demo |
Beta Was this translation helpful? Give feedback.
0 replies
-
无论那个开发工具代理也只是为开发服务。实现程序代理,你需要了解electron的的session拦截或者自定义协议去实现。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
引入axios后,在electron.vite.config.ts配置文件中增加了如下配置:
server: {
port: 8899, // 端口号
proxy: {
'/dev-api': {
target: 'http://localhost:8080', // 设置代理的目标地址
changeOrigin: true, // 允许跨域
pathRewrite: {
'/dev-api': ''
}
},
},
},
打包后请求无法正常发出,地址前缀变成了file:///D:,这如何处理???
"axios": "^1.6.2",
"electron": "^25.6.0",
"electron-vite": "^1.0.27",
"vite": "^4.4.9",
Beta Was this translation helpful? Give feedback.
All reactions