Skip to content
BunBase BunBase BunBase Docs Alpha v0.1.0

Configuration

BunBase is configured through environment variables (set at startup) and runtime settings (stored in the database, editable from Studio → Settings without restarting).

Runtime settings override env-var defaults and take effect within 60 seconds. They persist across restarts. Env vars are still used for security-sensitive values (SECRET_KEY, ADMIN_SECRET) and low-level infrastructure config (ports, worker count, storage provider).

These are stored in the _settings database table and configurable from Studio:

SettingDefaultDescription
maintenance_modefalseReturn 503 for all non-admin requests
log_levelinfoMinimum log level (debug, info, warn, error, off)
registration_opentrueAllow new user registrations
single_session_modefalseRevoke all other sessions on new login
require_email_verificationfalseFlag exposed on user object for use in collection rules
lockout_max_attempts10Failed login attempts before lockout
lockout_duration_ms900000Lockout duration in ms (default 15 min)
access_token_ttl_seconds900Access token lifetime in seconds (15 min default)
refresh_token_ttl_days30Refresh token lifetime in days
auth_password_enabledtrueAllow email + password login and registration
auth_magic_link_enabledtrueAllow passwordless magic-link login
auth_totp_enabledtrueAllow users to set up and use TOTP 2FA
auth_oauth_enabledtrueAllow OAuth provider login (GitHub, Google, OIDC)
auth_api_keys_enabledtrueAllow users to create API keys
auto_create_collectionstrueCreate collections on first write
auto_create_bucketsfalseCreate storage buckets on first upload
storage_cdn_urlCustom CDN base URL for storage downloads (e.g. https://cdn.example.com). When set, signed URLs use this domain as the base. The CDN must proxy requests to BunBase.
app_nameApp name used in email subjects
app_urlFrontend URL used in email callback links
email_providerconsoleconsole, resend, or smtp
email_fromSender address override
resend_api_keyResend API key
smtp_host, smtp_port, smtp_user, smtp_pass, smtp_secureSMTP configuration
rate_limit_public_reads200Per-IP, per-worker limit for unauthenticated reads
rate_limit_auth10Per-IP, per-worker limit for login/register/refresh
rate_limit_authenticated500Per-user, per-worker limit for authenticated CRUD
rate_limit_admin50Per-IP, per-worker limit for admin API
rate_limit_file_upload20Per-user, per-worker limit for file uploads
backup_auto_enabledfalseEnable scheduled automatic backups
backup_interval_minutes60How often to run an auto-backup (minutes)
backup_keep_recent_hours24Keep every backup from the last N hours
backup_keep_daily_days30Keep one backup per day for the last N days
backup_compression_formatzstdCompression format: zstd (faster, better ratio, .db.zst) or gzip (wider compat, .db.gz)
backup_compression_level6gzip level only: 1 = fastest, 9 = smallest (ignored when format is zstd)
backup_remote_typenoneRemote push destination: none, s3, or rsync
backup_remote_s3_endpointS3-compatible endpoint URL (blank → AWS S3)
backup_remote_s3_bucketDestination S3 bucket name
backup_remote_s3_regionus-east-1S3 region
backup_remote_s3_prefixOptional key prefix inside the bucket (e.g. backups/)
backup_remote_s3_access_key_idS3 access key ID
backup_remote_s3_secret_access_keyS3 secret access key
backup_remote_rsync_destrsync destination (e.g. user@host:/var/backups/)
access_log_max_rows10000Max rows to keep in the access log database (oldest deleted first)
app_log_max_rows10000Max rows to keep in the app log database (oldest deleted first)
access_log_max_age_days0Delete access logs older than N days (0 = disabled)
app_log_max_age_days0Delete app logs older than N days (0 = disabled)
oauth_github_client_idGitHub OAuth App client ID
oauth_github_client_secretGitHub OAuth App client secret
oauth_google_client_idGoogle OAuth client ID
oauth_google_client_secretGoogle OAuth client secret
oauth_oidc_issuerOIDC issuer URL (e.g. https://accounts.example.com)
oauth_oidc_client_idOIDC client ID
oauth_oidc_client_secretOIDC client secret
oauth_oidc_scopesopenid email profileSpace-separated OIDC scopes
VariableDefaultDescription
PORT8080HTTP port
NODE_ENVdevelopmentdevelopment, production, or test
PUBLIC_URLhttp://localhost:8080Backend origin — used for signed storage URLs and CORS
APP_URLsame as PUBLIC_URLFrontend app origin — used in email callback links (magic link, password reset, email verification). Set when your frontend runs on a different domain or port than the backend. Example: APP_URL=https://app.example.com
DATA_DIR./dataDirectory for SQLite database, local storage, and backups
VariableDefaultDescription
SECRET_KEY(dev default)Signs JWTs and local storage tokens. Required in production. Min 32 chars.
ADMIN_SECRET(dev default)Bearer token for admin API access. Required in production.
ALLOWED_ORIGINS*Comma-separated CORS origins. Use * for all, or list specific origins.
HSTSfalseSet to true to add Strict-Transport-Security header (use behind TLS).
VariableDefaultDescription
WORKER_COUNTcpu_count - 1Number of HTTP app workers
HTTP_WORKERStrueSet to false to serve HTTP from the main thread (single-process mode)
DB_MODEmainmain = DB in orchestrator; worker = dedicated DB Worker process
VariableDefaultDescription
STORAGE_PROVIDERlocallocal or s3
S3_ENDPOINTS3-compatible endpoint URL (required if STORAGE_PROVIDER=s3)
S3_BUCKETS3 bucket name
S3_REGIONS3 region
S3_ACCESS_KEY_IDAlso accepts AWS_ACCESS_KEY_ID
S3_SECRET_ACCESS_KEYAlso accepts AWS_SECRET_ACCESS_KEY

BunBase optionally integrates with Redis or Valkey for distributed rate limiting, cross-machine realtime fanout, and session caching. All features degrade gracefully when not configured.

VariableDefaultDescription
REDIS_URLRedis connection URL (e.g. redis://localhost:6379). If unset, Bun also checks VALKEY_URL.
VALKEY_URLValkey connection URL — identical protocol to Redis.

When configured, enables:

  • Distributed rate limiting — counters shared across all workers and machines (single true limit, no per-worker multiplication)
  • Cross-machine realtime fanout — WebSocket events published via Redis Pub/Sub reach clients on any machine
  • Session read cache — session existence cached in Redis, reducing DB worker RPC load on every authenticated request

See the Docker Compose file in docker/ for a ready-to-use Valkey setup.

Limits are per-IP (or per-user for authenticated/fileUpload routes) per minute.

Without Redis: tracked independently in each worker. Effective cluster budget = limit × WORKER_COUNT. With Redis: single shared counter across all workers and machines — limit is the true cluster-wide limit.

VariableDefaultKeyDescription
RATE_LIMIT_PUBLIC_READS200per-IPUnauthenticated GET endpoints
RATE_LIMIT_AUTH10per-IPLogin, register, token refresh
RATE_LIMIT_AUTHENTICATED500per-userAuthenticated CRUD and realtime
RATE_LIMIT_ADMIN50per-IPAdmin API endpoints
RATE_LIMIT_FILE_UPLOAD20per-userFile upload endpoints

All five limits are also configurable at runtime from Studio → Settings → Rate Limits without restarting.

VariableDefaultDescription
EMAIL_PROVIDERconsoleconsole (logs to stdout) or resend
EMAIL_FROMBunBase <noreply@localhost>Sender address
RESEND_API_KEYResend API key (required if EMAIL_PROVIDER=resend)
VariableDefaultDescription
LOCKOUT_MAX_ATTEMPTS10Failed login attempts before lockout
LOCKOUT_DURATION_MS900000Lockout duration in ms (default 15 minutes)
VariableDefaultDescription
LOG_LEVELinfoMinimum log level: debug, info, warn, error, or off
LOG_ACCESSstdoutAccess log destination: stdout or off