Skip to content

Latest commit

 

History

History
173 lines (172 loc) · 5.2 KB

settings.md

File metadata and controls

173 lines (172 loc) · 5.2 KB

Settings

Option Type Default value Purpose
case sensitive routing Boolean undefined When enabled, /Users and /users are different routes.
env String process.env.NODE_ENV || "development" Environment mode (like test, qa, stage, preview, production).
$ NODE_ENV=production node app
etag Boolean|String|Function "weak" The ETag response header.
app.set('etag', (body, encoding) => {
    return generateHash(body, encoding);
});
jsonp callback name String "callback" The default JSONP callback name.
json escape Boolean undefined Enable escaping the characters <, >, and & as Unicode escape sequences in JSON from a response of res.json(), res.jsonp(), and res.send().
json replacer Function|String[]|Number[] undefined The replacer argument used by JSON.stringify().
app.set('json replacer', (key, value) => {
    if (key == 'discount') {
        return undefined; // omit value
    } else {
        return value;
    }
});
json spaces Number|String undefined The space argument used by JSON.stringify().
app.set('json spaces', 4);
query parser String|Boolean|(String):Object "extended" Query parsing (?name=value&name2=value2):
  • false - disabled
  • "simple" - Node's querystring
  • "extended" - qs module (|| true)
strict routing Boolean undefined When enabled, /foo and /foo/ are different routes.
subdomain offset Number 2 The number of dot-separated parts of the host to remove to access subdomain.
  • 2: ncbi.nlm.nih.gov['nlm', 'ncbi']
  • 3: ncbi.nlm.nih.gov['ncbi']
trust proxy Boolean|String|String[]|Number|(ip):Boolean false Trust Proxy headers, e.g., X-Forwarded-Proto (req.protocol) and X-Forwarded-For (req.ips).
  • true - IP is leftmost entry in X-Forwarded-*
  • false - IP is in req.connection.remoteAddress
  • IP adresses to trust
    • 'loopback' - single subnet
    • 'loopback, 123.123.123.123' - subnet and IP address
    • 'loopback, linklocal, uniquelocal' - multiple subnets
    • ['loopback', 'linklocal', 'uniquelocal'] - multiple subnets (as array)
    Built-in values: loopback - 127.0.0.1/8, ::1/128; linklocal - 169.254.0.0/16, fe80::/10; uniquelocal - 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7
  • Number - trust the n-th hop from the front-facing proxy server as the client
  • custom function - custom implementation of trust
  • app.set('trust proxy', ip => {
        if (ip == '127.0.0.1' || ip == '123.123.123.123') {
            return true; // trusted IPs
        } else {
            return false;
        }
    });
    
views String|String[] process.cwd() + '/views' Directory (or directories) for the application's views.
app.set('views', path.join(__dirname, 'templates'));
view cache Boolean true in production, undefined otherwise View template compilation cache.
view engine String undefined Default engine extension to use when omitted.
x-powered-by Boolean true Enable the X-Powered-By: Express HTTP header.