Install and configureConfiguration

Configuration

Environment variables and secrets for self-hosted SlugBase: database, server URLs, security, registrations, and API docs.

What you need

  • A way to set environment variables for the process — typically a .env file, a Docker Compose env_file, or your server/orchestrator's secrets manager.
  • Strong random values for secrets (the server checks minimum lengths at startup and refuses to start if they are missing or too short).

For a quick start, copy .env.example from the repository to .env and fill in the required secrets before your first run.

Security and session variables

These are validated before the server starts listening for connections:

VariableRequirement
JWT_SECRETRequired. At least 32 characters and not the documented default placeholder string.
ENCRYPTION_KEYRequired. At least 32 characters.
SESSION_SECRETIn NODE_ENV=production, required with length at least 32. (In development, missing values may warn.)

Generate values with Node, for example:

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Run twice for separate JWT_SECRET and ENCRYPTION_KEY values.

Server and URLs

VariableRole
PORTHTTP listen port (default 5000).
NODE_ENVdevelopment or production. Production enables stricter session handling and static SPA serving.
BASE_URLPublic base URL of the app (used for redirects and cookie security logic). Default in code: http://localhost:5000. Set to your real HTTPS URL in production.
FRONTEND_URLOrigin allowed for CORS and related checks. Default: http://localhost:3000. For the bundled self-hosted UI on the same origin, set this to the same public URL as BASE_URL.
CORS_EXTRA_ORIGINSComma-separated extra allowed origins when needed.

Session cookies use secure: true when NODE_ENV=production and BASE_URL starts with https://, so HTTPS deployments should set BASE_URL to an https:// URL.

Database

VariableWhen
DB_TYPEsqlite (default) or postgresql.
DB_PATHSQLite file path (Dockerfile default /app/data/slugbase.db).
DATABASE_URLPostgreSQL connection string (alternative to discrete fields).
DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORDUsed when DB_TYPE=postgresql and DATABASE_URL is not set.

The application runs migrations automatically on startup.

Registrations

VariableRole
REGISTRATIONS_ENABLEDSet to false to disable new user sign-ups. Leave unset (or set to anything else) to keep registration open (default).

Email

SMTP is configured inside the app under Admin → Settings, not via environment variables. See Admin: SMTP email.

AI suggestions

AI suggestions are configured inside the app under Admin → AI Suggestions. See Admin: AI suggestions.

API documentation

VariableEffect
SLUGBASE_API_DOCSSet to false to hide the Swagger UI at /api-docs.

Troubleshooting