(1)开发环境
直接在package.json 里加命令
"serve": "vue-cli-service serve --disableHostCheck=true ",
注意加了才能用
proxy: {
'/xxxxx': {
target: 'xxxxx',//代理地址,这里设置的地址会代替axios中设置的baseURL
ws: true, proxy websockets
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
},
}
(2)生产环境:
disableHostCheck:true换成
allowedHosts:['.xxxx.com','.xxx.com'], 或者是all
参考webpack文档 (这个才是最官方!!!)
DevServer | webpack 中文文档
报错信息 be like
Dev Server has been initialized using an options object that does not match the API schema.
options has an unknown property 'disableHostCheck'