villadora/express-http-proxy

Make the user request available in proxyErrorHandler

Opened this issue · 0 comments

I'd like to use proxyErrorHandler to log errors for me, but currently it only provides the error, response, and next. I see that req is available in the function handleProxy, it just needs to be fed into resolver.

Alternatively, if there's a recommended way to access the request in the error handler I'm all ears. I'm using it like this:

const myApp = express();
myApp.use('/proxiedRequest', myMiddleware(), proxy('http://target.host.com', {
  proxyErrorHandler: (err, res, next) => {
    // TODO: report failure, including request url, headers, etc.
    next(err);
}