Express.js | app.enable() Function

Last Updated : 31 Aug, 2026

The app.enable() function is used to enable a Boolean setting in an Express application by setting its value to true. It is a shorthand for app.set(name, true) and is commonly used to enable built-in Express application settings such as trust proxy.

frame_4

Syntax:

app.enable(name)
  • Parameter: name — the name of the application setting to enable.
  • Return Value: Returns the Express application instance.

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();
app.enable('trust proxy')
console.log(app.get('trust proxy')) // true

Steps to run the program:

Run the index.js file using the below command:

node index.js

Output:

Screenshot-2026-08-19-170711

Example 2: Enabling a Boolean Setting

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

Steps to run the program:

Run the index.js file using the below command:

node index.js

Output:

Screenshot-2026-08-19-170711

Working of app.enable()

  • An Express application is created using express().
  • A Boolean application setting is selected.
  • app.enable() sets the selected setting to true.
  • Express uses the enabled setting when processing the application.
  • The setting can be checked using app.get() or app.enabled().

Use Cases of app.enable()

  • Enabling Boolean Express application settings.
  • Enabling trust proxy when the application runs behind a trusted reverse proxy.
  • Enabling case-sensitive routing.
  • Configuring application behavior using Express settings.
  • Simplifying app.set(name, true) operations.
Comment