Search code examples
javascriptnode.jsexpresshttp-headerswebserver

Can't get rid of header X-Powered-By:Express


I am running a server on nodejs with express. I can't seem to get rid of the header:

X-Powered-By:Express

I was wondering if there is any way to get rid of this header or do I have to live with it?


Solution

  • In Express >= 3.0.0rc5:

    app.disable('x-powered-by');
    

    Here is a simple middleware that removes the header in earlier versions of Express:

    app.use(function (req, res, next) {
      res.removeHeader("x-powered-by");
      next();
    });