manifest配置文件 devServer中的proxy设置一个没有问题,如下:
"proxy": {
"/api": {
"target": "http://www.xxx.com",
"changeOrigin": true
}
}
但是按照wepback官网配置多个编译的时候会报错。代码如下:
"proxy": [{
"context": ["/auth", "/api"],
"target": "http://www.xxx.com",
"changeOrigin": true
}]
错误信息如下:
When specified, "proxy" in package.json must be a string or an object.
Instead, the type of "proxy" was "object".
Either remove "proxy" from package.json, or make it an object.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tfw@0.1.0 dev:h5: cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tfw@0.1.0 dev:h5 script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2 个回复
7***@qq.com
它说的很清楚 When specified, "proxy" in package.json must be a string or an object. 当你指定proxy属性的时候,它必须是个对象 传array 肯定不认。 那么简单的写多个的话 可以类似这样
5***@qq.com
api改个api1都不行。