↑ ↓ to move · Enter to open · Esc to close

Core

Configuration

Every white.config.js setting with its default value.

A site needs a white.config.js only for what it changes. Everything has a default. The file lives in the project root and exports an object; .env in the same folder is loaded first.

js
// white.config.js
import { defineConfig } from 'white-js';

export default defineConfig({
  locale: 'en',
  trustProxy: 1,
  security: { cors: { origin: ['https://app.example.com'] } },
  plugins: ['./server/plugins/audit.js'],
});

defineConfig returns its argument unchanged; it exists so editors can complete and check the settings.

#Settings

Setting Default What it does
port PORT env, else 3000 Port to listen on
host null Address to listen on; null is all interfaces
locale 'en' Used by it.w.date() and it.w.number()
dev.reload true Refresh the browser when files change (white run dev only)
shutdownTimeout 10000 Milliseconds for the whole shutdown, handlers included
trustProxy false Behind a proxy: a hop count (1), subnets or 'loopback'. true is refused
requestId { header: 'x-request-id', accept: 'trusted' } Who may choose request ids
protocols { enforce: 'error', allow: [], block: [], definitions: [] } Protocol compatibility
dirs.routes 'server/routes' Route files
dirs.views 'app/views' Eta templates
dirs.public 'app/public' Static files
dirs.meta 'server/meta' Protocol metadata
dirs.migrations 'server/migrations' Your own protocol migrations
cookies.secret COOKIE_SECRET env Signs cookies; at least 16 characters, or a list for rotation
static { maxAge: '7d', versioned: '365d' } Static caching; false serves no files
compression true false turns it off; an object goes to the middleware
server { keepAliveTimeout: 65000, headersTimeout: 66000, requestTimeout: null } Node HTTP server timeouts in ms
log.level LOG_LEVEL env, else 'info' Logger level
env.required [] Variables that must exist at start-up
health { path: '/health', readyPath: '/ready', checks: {} } Health and readiness endpoints; false disables
security.helmet true Security headers; an object goes to helmet
security.csp true Content Security Policy with a per-request nonce
security.bodyLimit '100kb' Request body limit
security.rateLimit { windowMs: 60000, limit: 300, api: { limit: 60 } } Rate limits; false disables
security.origin { allowed: [] } CSRF origin check; false disables
security.cors false Cross-origin requests, see Security
mesh false Service-to-service infrastructure, see Services
plugins [] Plugins to load, see Plugins

#Mistakes are caught early

A misspelled setting would be ignored and the default used instead, which is hard to notice. A key that is one or two letters away from a real one is reported at start-up and by white doctor:

text
Unknown config key "plugin": did you mean "plugins"?

Invalid values (a port out of range, static.maxAge: 'forever', a cookies.secret that is too short) stop the start-up with every problem listed at once.

#Environment variables

.env is loaded automatically and never overwrites variables that already exist. Declare what the app needs and fail early when it is missing:

js
export default {
  env: { required: ['DATABASE_URL'] },
};

For typed access, see defineEnv in Cache, environment and shutdown.