Disable the identifying header
Reduce framework fingerprinting in production responses.
Express.js · Const
x-powered-by is a Boolean Express application setting enabled by default. It controls whether responses include the X-Powered-By: Express header.
Express stores this application setting as a Boolean that defaults to true. When enabled, responses include the X-Powered-By: Express header; use the application’s disable method with this setting name to turn it off.
app.set('x-powered-by', Boolean)x-powered-by, accepts a Boolean, and is enabled by default.X-Powered-By: Express response header.const express = require('express');
const app = express();
app.disable('x-powered-by');
app.get('/', (req, res) => {
res.send('Hello');
});
app.listen(3000);Creates an Express app and disables the identifying response header before serving requests.
Reduce framework fingerprinting in production responses.
Keep consistent application configuration across mounted Express applications.
Inspect or change framework response behavior during setup.
x-powered-by setting control?It is an Express application setting named x-powered-by. Its Boolean default is true, which enables the X-Powered-By: Express HTTP response header.
Follow-up: How would you disable it? Call app.disable('x-powered-by') during application setup.
Use app.disable('x-powered-by'). This disables the default header that identifies Express in responses.
Follow-up: Does disabling it guarantee that Express cannot be identified? No; the documentation says sophisticated attackers may still determine that the app uses Express.
The setting is inherited by sub-applications. Therefore, a mounted sub-app inherits the parent application's value unless its configuration changes it.
Follow-up: What type of setting is it? It is a Boolean application setting, and its default value is true.
app.disable()app.enable()app.enabled()app.get()trust proxy