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

tyronegcarter picture tyronegcarter · May 3, 2011 · Viewed 42.7k times · Source

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?

Answer

Giacomo picture Giacomo · May 3, 2011

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();
});