app.set(name, value) assigns an application setting. You can store any value; certain names (like views, view engine, trust proxy) configure Express itself.
view engine. Default extension so res.render('home') finds home.ejs.
Engine package. Install/register the engine (EJS often needs only npm i ejs).
Render. Route handlers call res.render using those settings.
Example 3 — Boolean Settings
set(true/false) matches enable / disable.
Express
const express = require('express');
const app = express();
app.set('x-powered-by', false); // same as app.disable('x-powered-by')
app.set('trust proxy', 1); // trust first hop (only behind your proxy)
console.log(app.get('x-powered-by')); // false
console.log(app.enabled('trust proxy')); // true
app.get('/', (req, res) => {
res.json({
poweredByOff: app.get('x-powered-by') === false,
ip: req.ip
});
});
app.listen(3000);
Output
false
true
GET /
→ { "poweredByOff": true, "ip": "..." }
(no X-Powered-By: Express header)
How It Works
Turn off header.x-powered-by: false hides Express branding.
trust proxy. Number 1 trusts the first proxy hop — only if you own that proxy.
Read flags.app.get / app.enabled confirm the state.
Effect. Later middleware and req.ip respect trust proxy.
Compatibility
Runtime Support
app.set() is an Express.js application method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers only see the effects (headers, rendered HTML).
✓ Server · Express 4 & 5
app.set()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
app.set()Express on Node.js
Bottom line: Call app.set during startup, then verify with app.get(name).
Frequently Asked Questions
It assigns an application setting name to a value. Special names (views, view engine, trust proxy, and others) configure Express; custom names store any value you need.
Use app.get(name) with one argument. Note: app.get(path, handler) with two arguments registers a GET route — different overload.
app.set(name, true) is the same as app.enable(name). app.set(name, false) is the same as app.disable(name).
Settings with a default value are generally not inherited (you must set them on the sub-app). Settings with no default are inherited. Official exceptions: trust proxy is inherited; view cache is not inherited in production.
No. It is a server-side Express configuration method on Node.js.