http - 如何在 ExpressJS 中删除 X-Powered-By

标签 http node.js http-headers express

我想删除 X-Powered-By 以确保安全,在 ExpressJS(node.js) 中保存带宽。怎么做? 可能是过滤器(app.use)?

app.use(function(req,res,next_cb){ /* remove X-Powered-By header */ next_cb(); }

最佳答案

不要删除它;让 Express 一开始就不要生成它:

https://stackoverflow.com/a/12484642/506073

转到您的 app.js,然后:

var app = express();

添加:

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

关于http - 如何在 ExpressJS 中删除 X-Powered-By,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10717685/

相关文章:

javascript - Express.js : Convert req. body 变成 POST 编码的字符串

node.js - NodeJs服务器上存储数据可靠吗?

axios - 使用 axios POST 请求传递 header

http - Cache-Control : max-age=0 and no-cache?有什么区别

json - Json RPC v2 over HTTP 的正确内容类型 header 是什么?

c++ - 我可以重复使用 TCP 连接吗?

java - 如何像在 Google Oauth Playground 中一样向 Google API 发送 HTTP 请求?

node.js - Passport 抛出 user.authenticate 不是一个函数

javascript - 手动 Bluebird promise 中的resolve()

apache - 带有查询字符串的 httpd 缓存规则