Commit 29107ca2 authored by cloudmu's avatar cloudmu Committed by Dan Abramov
Browse files

Send proper error response in custom onError handler for httpProxyMiddleware. (#588)

* Change http-proxy-middleware logLevel from silent to error

* provide onError handler for httpProxyMiddleware

* Send proper error reponse upon proxy error.
parent f4d9d8dc
No related merge requests found
Showing with 9 additions and 0 deletions
+9 -0
......@@ -184,6 +184,15 @@ function onProxyError(proxy) {
chalk.cyan(err.code) + ').'
);
console.log();
// And immediately send the proper error response to the client.
// Otherwise, the request will eventually timeout with ERR_EMPTY_RESPONSE on the client side.
if (res.writeHead && !res.headersSent) {
res.writeHead(500);
}
res.end('Proxy error: Could not proxy request ' + req.url + ' from ' +
host + ' to ' + proxy + ' (' + err.code + ').'
);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment