一、在代理target 下面添加onproxyReq
1688550258918.png
const target = 'localhost:8080/api'
proxy: {
'/api': {
target: target,
onProxyReq (proxyReq) {
if (proxyReq.getHeader('origin')) {
proxyReq.setHeader('origin', target)
}
},
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
}
}
网友评论