javascriptnode.jsexpress

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


Solution

  • That could be as simple as adding this middleware:

    app.use(function(req, res, next) {
      delete req.headers['header-name']; // should be lowercase
      next();
    });