function customHeaders( req, res, next ){
// Switch off the default 'X-Powered-By: Express' header
app.disable( 'x-powered-by' );
// OR set your own header here
res.setHeader( 'X-Powered-By', 'Awesome App v0.0.1' );
// .. other headers here
next()
}
app.use( customHeaders );
// ... now your code goes here
在这种情况下,设置 X-Powered 将覆盖默认的“ Express”,因此您不需要同时禁用 AND 设置新值。