In Express.js, app.enable(name) turns a Boolean application setting on by setting it to true. It is the readable shorthand for app.set(name, true).
A common case is app.enable('trust proxy') when you sit behind a reverse proxy. Pair it with app.enabled() to confirm, and app.disable() to turn the flag off again.
Syntax
Call app.enable in your Express.js app. Start with this line.
Express
app.enable(name)
Call
What it does
app.enable(name)
Primary signature.
Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.
GET / (behind a proxy that sets X-Forwarded-For / X-Forwarded-Proto)
→ { "ip": "203.0.113.10", "secure": true }
(Values come from forwarded headers when trust proxy is on.)
How It Works
Create the app. Settings apply to this Express instance.
Enable early.app.enable('trust proxy') sets the flag to true before requests arrive.
Read request helpers.req.ip and req.secure can use forwarded headers.
Only behind a trusted proxy. Do not enable this on a public internet-facing process with no proxy.
Example 2 — Enable and Confirm
Show that app.enable matches app.set(..., true), then read it back.
Gate on environment. Only production calls app.enable('trust proxy').
Leave other defaults.x-powered-by stays on unless you disable it.
Expose the state. The status route reports app.enabled(...) for each flag.
Dev stays simple. Without production, trust proxy remains off (Express default).
Compatibility
Runtime Support
app.enable() is an Express.js application method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not call it — they only see the resulting HTTP behavior.
✓ Server · Express 4 & 5
app.enable()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
app.enable()Express on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.
Frequently Asked Questions
It sets a named Boolean application setting to true. It is the same as calling app.set(name, true) for that setting.
When your app sits behind a reverse proxy and you want Express to trust X-Forwarded-* headers for the client IP and protocol.
Use app.enabled(name), which returns true when the setting is on. You can also read the raw value with app.get(name).
Yes. Call app.disable(name), which is the same as app.set(name, false).
No. It configures your Express server on Node.js. Browsers only receive the resulting HTTP behavior.