Express.js | app.enabled() Function

Last Updated : 31 Aug, 2026

The app.enabled() function checks whether a Boolean setting is enabled in an Express application. It returns true if the specified setting is enabled and false if the setting is disabled. 

frame_6

Syntax:

app.enabled(name)
  • Parameter: name — the name of the application setting to check.
  • Return Value: Returns a Boolean value (true or false).

Installation of the express module:

You can visit the link to Install the express module. You can install this package by using this command.

npm install express

After installing the express module, you can check your express version in the command prompt using the command.

npm version express

After that, you can just create a folder and add a file, for example, index.js. To run this file you need to run the following command.

node index.js

Project Structure:

Screenshot-2026-08-03-153443

Filename: index.js 

javascript
const express = require('express');
const app = express();
console.log(app.enabled('trust proxy')) // false
app.enable('trust proxy')
console.log(app.enabled('trust proxy')) // true

Steps to run the program:

Run the index.js file using the below command:

node index.js

Output:

Screenshot-2026-08-21-091437

Example 2: Checking a Disabled Setting

JavaScript
const express = require('express');
const app = express();
app.disable('case sensitive routing');
console.log(app.enabled('case sensitive routing')); // false

Steps to run the program:

Run the index.js file using the below command:

node index.js

Output:

Screenshot-2026-08-21-093554

Working of app.enabled()

  • An Express application is created using express().
  • An application setting is selected.
  • app.enabled() checks the current value of the setting.
  • It returns true if the setting is enabled.
  • Otherwise, it returns false.

Use Cases of app.enabled()

  • Checking whether an Express application setting is enabled.
  • Verifying settings configured using app.enable().
  • Checking whether a setting has been disabled using app.disable().
  • Controlling application behavior based on configuration settings.
  • Checking Boolean Express application settings before processing requests.
Comment