I have an issue with Vite+Vue3 project.
I used Vite proxy to fetch data via api and it's working well in local.
But 404 error is caused when it's deployed to Vercel.com.
Vite configuration is like this.
// vite.config.ts
server: {
port: 4000,
proxy: {
// 选项写法
'/api': {
target: 'http://xxx.xxx.xxx.xxx:9998',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
},
hmr: {
overlay: false
},
host: '0.0.0.0'
},
I used this template: https://github.com/kailong321200875/vue-element-plus-admin
It's deployed to http://his-lemon.vercel.app/
The error is the same as in both Vite 2 and Vite 3.
How can I fix this?