Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a header from express req object?

I'm trying to figure out how to remove header from req object in express. I believe this res.disable("Header Name") removes it from res object, but same doesn't work for req.headers

like image 543
Ilja Avatar asked Jan 31 '23 01:01

Ilja


1 Answers

That could be as simple as adding this middleware:

app.use(function(req, res, next) {
  delete req.headers['header-name']; // should be lowercase
  next();
});
like image 106
robertklep Avatar answered Feb 02 '23 04:02

robertklep