Configuration
Trelay is configured via environment variables. Use a .env file in the project root (or set variables in your shell or Docker). The app loads .env automatically when present.
Required variables
| Variable | Description |
|---|
API_KEY | Secret used to authenticate API requests and dashboard login. Use a long random string (e.g. openssl rand -hex 32). |
JWT_SECRET | Secret used to sign JWT tokens. Use a long random string. Keep it private. |
Server
| Variable | Description | Default |
|---|
SERVER_HOST | Bind address | 0.0.0.0 |
SERVER_PORT | HTTP port | 8080 |
SERVER_READ_TIMEOUT | Read timeout (e.g. 10s) | 10s |
SERVER_WRITE_TIMEOUT | Write timeout (e.g. 30s) | 30s |
SERVER_SHUTDOWN_TIMEOUT | Graceful shutdown timeout | 10s |
Database
| Variable | Description | Default |
|---|
DB_DRIVER | sqlite3 or postgres | sqlite3 |
DB_PATH | SQLite database file path (used when DB_DRIVER=sqlite3) | trelay.db |
DB_URL | PostgreSQL connection string (when DB_DRIVER=postgres) | — |
DB_MAX_CONNS | Max DB connections (Postgres) | 10 |
Authentication
| Variable | Description | Default |
|---|
TOKEN_EXPIRY | JWT token lifetime (e.g. 24h) | 24h |
Application
| Variable | Description | Default |
|---|
BASE_URL | Public URL for short links (e.g. https://links.example.com) | http://localhost:8080 |
DEFAULT_DOMAIN | Default domain for new links (optional) | — |
CUSTOM_DOMAINS | Comma-separated list of allowed custom domains | — |
STATIC_DIR | Path to frontend build output (serve SPA from server) | — |
ANALYTICS_ENABLED | Enable click tracking | true |
IP_ANONYMIZATION | Anonymize IP addresses in analytics | true |
SLUG_LENGTH | Default length for auto-generated slugs (4–32) | 6 |
MAX_URL_LENGTH | Maximum length of original URLs | 2048 |
RATE_LIMIT_PER_MIN | API rate limit (requests per minute per client) | 100 |
Example .env
# Required
API_KEY=your_secure_api_key_here
JWT_SECRET=your_secure_jwt_secret_here
# Server
SERVER_PORT=8080
# Database (SQLite)
DB_DRIVER=sqlite3
DB_PATH=trelay.db
# Public URL for short links
BASE_URL=https://links.example.com
# Optional
ANALYTICS_ENABLED=true
IP_ANONYMIZATION=true
RATE_LIMIT_PER_MIN=100