配置 vue.config.js
devServer: {
open: true,
host: 'localhost',
port: 8080,
https: false,
proxy: { // 跨域配置
'/': {
target: 'http://192.168.7.52:8080',
changeOrigin: true,
ws: false,
pathRewrite: {
'^/': ''
}
}
},
},
此时浏览器中的请求访问地址为 localhost:8080/***
访问的真实地址是http://192.168.7.52:8080/***