Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Express.js · Module

app.enable

Enables a named Boolean setting on an Express application. It returns the application instance and is equivalent to setting that Boolean property to true.

How it works

Calling app.enable(name) changes the named Boolean application setting to true and returns the application object, so the call can be chained. The setting name must be one of the properties listed in Express's application settings table.

Syntax

app.enable(name)

Parameters

NameTypeDescription
nameStringThe Boolean application-setting name to enable; it must be a property from the application settings table.

Returns

Application

Key points

  • The method changes the selected Boolean application setting to enabled.
  • For Boolean properties, app.set(name, true) provides equivalent behavior.
  • The documentation demonstrates enabling trust proxy and reading the resulting value as true.
  • Invoke the method on an Express application object created by the framework.

Common mistakes

  • Only use setting names documented in the application settings table; this method is specifically for Boolean settings.

Example: Enable a Boolean application setting

const express = require('express');
const app = express();

app.enable('trust proxy');
console.log(app.get('trust proxy'));

Creates an Express application, enables the Boolean trust proxy setting, and reads it back as true.

When to use it

Configure proxy trust

Enable proxy-related application behavior before registering routes or middleware.

Apply application configuration

Turn on a documented Boolean Express application setting during startup.

Chain configuration calls

Enable a setting while retaining the application object for fluent setup code.

Interview questions

QWhat does app.enable() do, and what does it return?

app.enable(name) sets the named Boolean application setting to true and returns the Express application. For example, enabling trust proxy makes app.get('trust proxy') return true.

Follow-up: How else can the same Boolean setting be enabled? app.set('foo', true) is equivalent when foo is a Boolean property.

QWhat argument does app.enable() accept?

The argument is the setting name, represented as a string. It must identify one of the Boolean properties in the application settings table.

Follow-up: What happens for a non-Boolean setting? Use the setting-specific API or app.set() rather than treating it as an enable/disable flag.

QHow can you verify the setting enabled by app.enable()?

A typical use is app.enable('trust proxy'), which enables proxy-trust behavior for the application. The setting can then be inspected with app.get('trust proxy') or app.enabled('trust proxy').

Follow-up: How would you turn the setting off? Call app.disable('trust proxy'), then app.disabled('trust proxy') reports true.

  • app.set()
  • app.get()
  • app.enabled()
  • app.disable()
  • app.disabled()

Source: Application Object · Express.js 4.x. Checked 2026-10-15.