2.配置示例
devServer: {
proxy: {
'/pdf': {
target: 'http://61.186.254.137:20001',
changeOrigin: true,
pathRewrite: {
'^/pdf': ''
}
}
}
2.说明
- 这个时候, 项目中如果有地址出现跨域,根据上面的规则,路径写成以下方式:
pdf/sources/getPdfText - 经过代理的配置后,实际请求的路径会变成:
http://61.186.254.137:20001/sources/getPdfText
2.多个跨域配置
devServer: {
proxy: {
'/pdf': {
target: 'http://61.186.254.137:20001',
changeOrigin: true,
pathRewrite: {
'^/pdf': ''
}
},
'api': {
target: 'http://61.186.224.168:50008',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
},
'sour': {
target: 'http://61.156.159.126:40023',
changeOrigin: true,
pathRewrite: {
'^/sour': 'sour'
}
}
}
|