{
devServer: {
proxy: {
'/api': {
target: 'https://other-server.example.com',
secure: false,
changeOrigin: true,
pathRewrite: {
"^/api": "/"
}
},
'/test': {
target: 'https://other-server.example2.com',
secure: false,
changeOrigin: true,
pathRewrite: {
"^/test": "/"
}
}
}
}
}
这样写貌似不能?求教如何做?
假设接口服务器在
https://other-server.example.com
,本地服务器是http://localhost:3000
原接口
https://other-server.example.com/api/get/something
代理到http://localhost:3000/api/api/get/something
可能是重写规则错了导致 url 解析不正确