在create-react-app的package.json里,想设置多个代理
{
"proxy":{
"/api": {
"target": "http://0.0.0.89:7300",
"ws": true
},
"/foo": {
"target": "http://0.0.11.22:8848",
"ws": true
}
}
}
然后npm statr报错:
When specified, "proxy" in package.json must be a string.
Instead, the type of "proxy" was "object".
Either remove "proxy" from package.json, or make it a string.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! r-d-m@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
求助,谢谢!!
如果是用React,请参考以下的文章
https://github.com/facebook/c...
总结是要安装http-proxy-middleware,然后将你的proxy设置搬到src/setupProx.js里。如以下: