vue.config.js里配置
module.exports = {
publicPath: ‘./’ ,
devServer: {
open: true, //是否自动弹出浏览器页面
host: “localhost”,
port: ‘8090’,
proxy: {
‘/api’: { // search为转发路径
target: ‘http://192.168.0.124:8090/’, // 目标地址
changeOrigin: true, // 设置同源 默认false,是否需要改变原始主机头为目标URL,
ws: true, //代理websockets
pathRewrite: { // 重写路径: 当检测到请求地址里包含 /v1 时,将此路径进行跨域代理操作
‘^/api’: ‘’
}
}
}
},
}