vite.config.js配置如下
server: {
port: 8052, //设置服务启动端口号,是一个可选项,不要设置为本机的端口号,可能会发生冲突
open: true, //是否自动打开浏览器,可选项
cors: true, //允许跨域。
// 设置代理
proxy: {
'/': {
target: 'http://localhost:8053/', //这是你要跨域请求的地址前缀
changeOrigin: true //开启跨域
}
}
}