umijs / umi-request

A request tool based on fetch.
2.2k stars 336 forks source link

使用extend方法封装请求,开发环境下proxy请求到的真实地址报404 #309

Closed zhilianbi520 closed 1 year ago

zhilianbi520 commented 1 year ago
proxy设置为:
"/api/customerManage": {
        "target": `http://www.abc.com/customerManage`,// 开发
        "changeOrigin": true,
        "pathRewrite": { "^/api/customerManage": "" }
}

代理请求的Request URL:http://localhost:8080/api/customerManage/abc
显示的x-real-url:http://www.abc.com/api/Manage/abc
期望的x-real-url:http://www.abc.com/abc

将customerManage替换成其他xxManage均可请求到正确地址,只有该字段会有此问题,求解。

zhilianbi520 commented 1 year ago

前面有配置另一个代理导致该问题:

"/api/customer": {
  "target": `http://www.abc.com/customer`,
  "changeOrigin": true,
  "pathRewrite": { "^/api/customer": "" }
}