无法摆脱标题 X-Powered-By:Express [英] Can't get rid of header X-Powered-By:Express
本文介绍了无法摆脱标题 X-Powered-By:Express的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 express 在 nodejs 上运行服务器.我似乎无法摆脱标题:
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?
推荐答案
In Express >= 3.0.0rc5:
In Express >= 3.0.0rc5:
app.disable('x-powered-by');
这是一个简单的中间件,它在早期版本的 Express 中删除了标头:
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();
});
这篇关于无法摆脱标题 X-Powered-By:Express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文