在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 start 报错
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
求助,谢谢!!
在package.json中查看你的react-scripts的版本号 版本太高可能不支持 把node_modules/react-scripts删除了 重新安装 npm i react-scripts@1.1.1 --save