Home Express.js Application app.disabled() Express.js app.disabled() Method Definition In Express.js, app.disabled(name) returns true when a Boolean application setting is currently false (off). It is a read-only check — it never changes settings.
Use it after app.disable() (or instead of comparing app.get(name) === false). The opposite helper is app.enabled() .
Syntax Call app.disabled in your Express.js app. Start with this line.
Call What it does app.disabled(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.
Library declarations const express = require("express");
const app = express();
app.disabled(name) Parameters Parameter Description name Required. Boolean setting to test — for example 'trust proxy' or 'x-powered-by'. true Required. The setting value is false (disabled). false Required. The setting is not disabled (enabled / truthy).
Return Value app.disabled(name) returns a Boolean: true if the setting is disabled (false), otherwise false. It does not change any setting.
app.disable('x-powered-by');
app.disabled('x-powered-by'); // true
app.disabled('etag'); // false when etag is still enabled Express.js Examples 1. Official check pattern 2. Check x-powered-by 3. Branch on disabled Example 1 — Official Check Pattern Disable a setting, then confirm with app.disabled() (same idea as the Express docs).
const express = require('express');
const app = express();
app.disable('trust proxy');
console.log(app.disabled('trust proxy')); // true
app.enable('trust proxy');
console.log(app.disabled('trust proxy')); // false
app.listen(3000); How It Works Turn the flag off. app.disable('trust proxy') stores false.Ask “is it disabled?” app.disabled(...) returns true.Turn it back on. app.enable('trust proxy') stores true.Ask again. Now app.disabled(...) returns false.Example 2 — Check x-powered-by See the default (on), then disable and re-check.
const express = require('express');
const app = express();
console.log(app.disabled('x-powered-by')); // false (default is on)
console.log(app.get('x-powered-by')); // true
app.disable('x-powered-by');
console.log(app.disabled('x-powered-by')); // true
console.log(app.enabled('x-powered-by')); // false
app.listen(3000); How It Works Default is on. Before changes, app.disabled('x-powered-by') is false.Raw value. app.get(...) shows the stored Boolean (true).Disable. app.disable(...) turns the flag off.Helpers agree. disabled becomes true; enabled becomes false.Example 3 — Branch on disabled Use the check in a status route so ops can confirm production hardening.
const express = require('express');
const app = express();
if (process.env.NODE_ENV === 'production') {
app.disable('x-powered-by');
}
app.get('/status', (req, res) => {
res.json({
poweredByHidden: app.disabled('x-powered-by'),
trustProxyOff: app.disabled('trust proxy')
});
});
app.listen(3000); NODE_ENV=production → GET /status
{ "poweredByHidden": true, "trustProxyOff": true }
NODE_ENV unset → GET /status
{ "poweredByHidden": false, "trustProxyOff": true } How It Works Optional disable. Production turns x-powered-by off.Default trust proxy. Stays off unless you enable it — so trustProxyOff is usually true.Read in a route. app.disabled(...) reports current state as JSON.No mutation. The check only reads; it never flips the setting.Compatibility
Runtime Support app.disabled() is an Express.js application method . It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not call it.
✓ Server · Express 4 & 5
app.disabled() Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.
Server Node.js runtime API
Node.js 18+ for Express 5 · 14+ typical for Express 4
Supported
Bun Express-compatible server apps
Supported
Deno Via npm compatibility / adapters
Supported app.disabled() 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 What does Express.js app.disabled() do? It returns true when a named Boolean application setting is false (disabled). It only reads the setting — it does not change it.
How is app.disabled() different from app.disable()? app.disable(name) turns the setting off. app.disabled(name) only checks whether it is currently off.
How does app.disabled() relate to app.enabled()? They are opposite checks. If app.disabled(name) is true, then app.enabled(name) is false for a Boolean setting.
Should I use app.disabled() or app.get()? Use app.disabled(name) when you want a clear yes/no “is it off?” answer. Use app.get(name) when you need the raw stored value.
Can browsers run app.disabled()? No. It runs on your Express server in Node.js. Browsers only see the HTTP result of your app’s settings.
CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion