yorick
yorick
  • 发布:2021-06-23 14:45
  • 更新:2021-06-23 14:45
  • 阅读:2499

【报Bug】H5端 manifest.json 下的devServer=>proxy配置出错 Could not proxy request

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 10.14.6

HBuilderX类型: Alpha

HBuilderX版本号: 3.1.19

浏览器平台: Chrome

浏览器版本: 85.0.4183.102(正式版本) (64 位)

项目创建方式: HBuilderX

操作步骤:

使用最新版的HbuilderX,
manifest.json 下面 H5配置如下:
...
"h5": {
"router": {
"mode": "history",
"base": "/front2"
},
"devServer": {
"port": 8080,
/浏览器自动打开页面/
"open": true,
"proxy": {
"/api": {
"target": "https://xxx.xxxx.cn",
"ws": true,
"changeOrigin": true,
"pathRewrite": {
"^/api": ""
}
}
}
},
...

预期结果:

请求接口会使用devServer=>proxy=>target的host地址

实际结果:

请求接口会使用 http://localhost:8080 报错如下
Proxy error: Could not proxy request /member/profile/overview from localhost:8080 to https://xxx.xxxx.cn.
14:29:28.550 See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (EPROTO).

bug描述:

更新HBuilder X 最新版后,无法请求到正确的api地址,
devServer下配置的proxy没有生效,
应该是从“内置node版本升级为12.22”这个版本开始的,
切回之前的版本 就能正常,之后的版本都有这个问题

manifest.json 下面 H5配置如下:
...
"h5": {
"router": {
"mode": "history",
"base": "/front2"
},
"devServer": {
"port": 8080,
/浏览器自动打开页面/
"open": true,
"proxy": {
"/api": {
"target": "https://xxx.xxxx.cn",
"ws": true,
"changeOrigin": true,
"pathRewrite": {
"^/api": ""
}
}
}
},
...

运行H5到Chorme,报错如下:

Proxy error: Could not proxy request /member/profile/overview from localhost:8080 to https://xxx.xxxx.cn.
14:29:28.550 See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (EPROTO).

2021-06-23 14:45 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复