Skip to content

Commit 25bb3bf

Browse files
philjacksonindexzero
authored andcommitted
Update the README to describe middleware err handler.
1 parent bc12ca3 commit 25bb3bf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,17 @@ A regular request we receive is to support the modification of html/xml content
441441

442442
[Harmon](https://github.com/No9/harmon/) is a stream based middleware plugin that is designed to solve that problem in the most effective way possible.
443443

444+
If you would like to handle errors passed to `next()` then attach a listener to the proxy:
445+
446+
server = httpProxy.createServer(
447+
myMiddleWare,
448+
9000, 'localhost'
449+
).listen(8000);
450+
451+
server.proxy.on('middlewareError', function (err, res, req) {
452+
// handle the error here and call res.end()
453+
});
454+
444455
## Proxying WebSockets
445456
Websockets are handled automatically when using `httpProxy.createServer()`, however, if you supply a callback inside the createServer call, you will need to handle the 'upgrade' proxy event yourself. Here's how:
446457

0 commit comments

Comments
 (0)