app.enable() / app.disable()

Sets a Boolean app setting to true or false.

Since Express 4 Spec ↗

Syntax

app.enable(name)  /  app.disable(name)

Parameters

NameTypeRequiredDescription
name string Yes The Boolean setting name, e.g. `'x-powered-by'`, `'strict routing'`, `'case sensitive routing'`.

Returns

Application — The app instance, for chaining.

Examples

app.disable('x-powered-by');
console.log(app.enabled('x-powered-by'));
Output
false
app.enable('strict routing');
app.enable('case sensitive routing');

Notes

`app.disable('x-powered-by')` removes the `X-Powered-By: Express` response header, a small but recommended security hardening step. Equivalent to `app.set(name, true|false)`; check with `app.enabled` / `app.disabled`.

See also