使用proxy进行反向代理(proxy代理拦截)
vue.config.js 文件中
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:7788',
ws: true,
changeOrigin: true,
pathRewirte:{ //路径重写,避免代理服务器在端口后面加上/api,导致请求失败404
'^/api':''
}
},
'/foo':{
target:'http://localhost:3001'
}
}
}
}
proxy解决跨域
于 2023-10-24 00:31:38 首次发布