http-proxy-middleware icon indicating copy to clipboard operation
http-proxy-middleware copied to clipboard

Bug: Error in browser shows original not target host.

Open jraedisch opened this issue 5 years ago • 0 comments

Is this a bug report?

Yes. (A mild one.)

I got referred from parcel: https://github.com/parcel-bundler/parcel/issues/5725

Version: [email protected]

TL;DR

When proxy target is not running, the error message in the browser shows the origin, not the target host, which is misleading.

Long:

I have a .proxyrc.json

{
  "/api": {
    "target": "http://foobar/",
    "pathRewrite": {
      "^/api": ""
    }
  }
}

When target is not running, I get the err in browser:

Error occured while trying to proxy to: localhost/upload

when opening

http://localhost/api/upload

which is misleading. I would prefer

Error occured while trying to proxy to: foobar/upload

Tracked it down to https://github.com/chimurai/http-proxy-middleware/blob/master/src/handlers.ts but do not know, what to change for a PR, and for which project.

jraedisch avatar Jan 28 '21 10:01 jraedisch