Express.js | app.disable() Function

Last Updated : 31 Aug, 2026

The app.disable() function is used to disable a Boolean setting in an Express application by setting its value to false. It is a shorthand for app.set(name, false) and can be used to disable Boolean Express application settings. 

frame_5

Syntax:

app.disable(name)
  • Parameter: name — the name of the application setting to disable.
  • 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');
app.disable('trust proxy');
console.log(app.get('trust proxy')); // false

Steps to run the program:

Run the index.js file using the below command:

node index.js

Output:

Screenshot-2026-08-19-175023

Working of app.disable()

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

Use Cases of app.disable()

  • Disabling Boolean Express application settings.
  • Disabling trust proxy when it is not required.
  • Disabling case-sensitive routing.
  • Configuring application behavior using Express settings.
  • Simplifying app.set(name, false) operations.
Comment