Uh oh!
There was an error while loading. Please reload this page.
Provide custom onError handler for http-proxy-middleware - #502
Conversation
gaearon
commented
Aug 27, 2016
This error message looks very confusing and aggressive. Can we improve the error output of this Node module first, to be readable in common cases? |
Personally I think the error message (as is) might still be better than being silent. It gives some hints, such as keyword "Proxy Error", standard POSIX error code, and the hostname and targetUri the proxy failed to access. However I totally understand the concern and CRA's principled approach of being beginner friendly. I looked into how the error messages (with error codes such as ECONNREFUSED) is formulated:
So as @gaearon suggested, the straightforward approach may be to improve the error output in http-proxy-middleware (or http-proxy). The logError implementation can simply reference the NodeJS common System Error page (as a link), and/or print out the plain text explanations mapped to the common errors such as ECONNREFUSED, ECONNRESET, and ETIMEDOUT. |
geowarin
commented
Aug 28, 2016
Errno is a cool npm package for the purpose of translating node's errors |
gaearon
commented
Aug 28, 2016
Sounds good to me, would you like to send a PR to |
Yes I can do a PR to http-proxy-middleware. So we can either
Any preference? |
gaearon
commented
Sep 2, 2016
We decided to update this to use |
cloudmu
commented
Sep 2, 2016
@gaearon Yes we decided to use onError. Just got around to implement it. Two options with slight differences. 2 Cyan color for url and links: Any preference? I will check in code later on. |
gaearon
commented
Sep 2, 2016
Let’s make it |
cloudmu
commented
Sep 2, 2016
gaearon
commented
Sep 2, 2016
Hmm. It’s still a bit too easy to miss it. Maybe try |
cloudmu
commented
Sep 2, 2016
gaearon
commented
Sep 2, 2016
This looks good. |
Let’s do the second one. I would probably remove cyan from Node docs link and maybe add cyan to the error code instead. Also could try putting the whole second line into |
cloudmu
commented
Sep 2, 2016
gaearon
commented
Sep 3, 2016
Beautiful work. Thanks. |
gaearon
commented
Sep 3, 2016
Out in 0.4.1! |
* Change http-proxy-middleware logLevel from silent to error * provide onError handler for httpProxyMiddleware
* Change http-proxy-middleware logLevel from silent to error * provide onError handler for httpProxyMiddleware
lileilei
commented
Dec 1, 2017
http-party/node-http-proxy#579 Look at this issue! |






This will change the http-proxy-middle logLevel option from 'silent' to 'error' in development mode.
Errors are bound to occur when proxying API requests to an API server during development, for various reasons such as forgetting to start the API server or using an incorrect port. With 'silent' option, no error message will be shown in the command line console at all, which can be confusing. With 'error' option, the console will show a very concise and informative error message, which helps to quickly pinpoint to the issues.
For example, following is an example of the error message (caused by not starting the API server) in the command line console: