You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to check specific headers (say X-API-Key) and cancel the proxy request if they are incorrect.
We've tried putting the logic in a filter() function but return false does not cancel the request - it passes the request on to the next handler in express. Even if we .status(401).send().end() the request is still passed on to the next handler.
filter: function(req,res){if(req.header('x-api-key')!=='secretkey'){res.status(401).send('Invalid X-API-Key!').end();// This works for the clientreturnfalse;// This causes an express error on the server}returntrue;},
How can we cancel/block the request from being proxied?
The text was updated successfully, but these errors were encountered:
We want to check specific headers (say X-API-Key) and cancel the proxy request if they are incorrect.
We've tried putting the logic in a
filter()
function butreturn false
does not cancel the request - it passes the request on to the next handler in express. Even if we.status(401).send().end()
the request is still passed on to the next handler.How can we cancel/block the request from being proxied?
The text was updated successfully, but these errors were encountered: