.env.example to .env and configure the following:
General
DATABASE_URL
Required — PostgreSQL connection string.postgresql://[user]:[password]@[host]:[port]/[database]
For Docker Compose, use the service name as host:
CORS_ORIGIN
Required — Allowed origin for CORS requests (web frontend URL).ENVIRONMENT
Optional — Application environment. Defaults todevelopment.
SERVER_URL
Required — Base URL where the server is accessible.- Generating download links
- Email template URLs
- OAuth redirect URIs
NANAHOSHI_DATA_PATH
Optional — Directory for storing covers, thumbnails, and cache. Defaults to./data.
/app/apps/server/data.
NAMESPACE_UUID
Required — Stable UUID namespace for generating deterministic book IDs.DOWNLOAD_SECRET
Required — Secret key for signing download URLs.Authentication
BETTER_AUTH_SECRET
Required — Secret key for signing session tokens. Must be at least 32 characters.BETTER_AUTH_URL
Required — Base URL for better-auth callbacks. Must matchSERVER_URL.
DISCORD_CLIENT_ID
Optional — Discord OAuth client ID.DISCORD_CLIENT_SECRET
Optional — Discord OAuth client secret.Discord OAuth is optional. Users can always register with email/password.
Web (build-time)
VITE_SERVER_URL
Required — URL the browser uses to reach the API server.SMTP (email)
SMTP configuration for sending verification emails, password resets, and invitations.SMTP_HOST
Required — SMTP server hostname.SMTP_PORT
Required — SMTP server port.465— SSL/TLS (most common)587— STARTTLS25— Unencrypted (not recommended)
SMTP_SECURE
Required — Use SSL/TLS connection.true for port 465, false for 587.
SMTP_USER
Required — SMTP authentication username (usually your email).SMTP_PASS
Required — SMTP authentication password.Elasticsearch
ELASTICSEARCH_NODE
Required — Elasticsearch connection URL.ELASTICSEARCH_INDEX_PREFIX
Optional — Prefix for Elasticsearch indices. Defaults tonanahoshi.
${prefix}_books (e.g., nanahoshi_books).
Redis
REDIS_HOST
Required — Redis server hostname.REDIS_PORT
Required — Redis server port.REDIS_PASSWORD
Required — Redis authentication password.Docker Compose only
These variables are only used indocker-compose.yml and do not affect bare-metal deployments.
POSTGRES_PASSWORD
Required — Password for the PostgreSQL container.DATABASE_URL.
SERVER_PORT
Optional — Host port to expose the server on. Defaults to3000.
WEB_PORT
Optional — Host port to expose the web frontend on. Defaults to3001.
Validation
Environment variables are validated at startup using@t3-oss/env-core and Zod in packages/env/src/server.ts. Missing or invalid variables will cause the server to exit with an error.
To check your configuration: