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 1:
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();
});
Solution 2:
Just to piggy-back on rjack's answer, you could also (optionally) just change (set) the X-powered-by header to something much cooler/custom like this:
app.use(function (req, res, next) {
res.header("X-powered-by", "Blood, sweat, and tears")
next()
})