Configuration

Environment Variables

Server

VariableDefaultDescription
IP_SERVER127.0.0.1Listening IP address
PORT3000Server port
DEBUGtrueDebug mode (templates, logs, etc.)

⚠️ Production: Set DEBUG=false explicitly. In debug mode, detailed error pages are visible, potentially revealing sensitive information. Also, compiling with cargo build --release automatically disables debug assertions, but DEBUG=true may override this.


Database

VariableDefaultDescription
DATABASE_URLFull connection string
DB_ENGINEpostgrespostgres, sqlite, mysql
DB_USERpostgresDB user
DB_PASSWORDDB password
DB_HOSTlocalhostDB host
DB_PORT5432DB port
DB_NAMEruniqueDatabase name

PostgreSQL:

DATABASE_URL=postgres://user:password@localhost:5432/dbname
DB_ENGINE=postgres
DB_USER=postgres
DB_PASSWORD=secret
DB_HOST=localhost
DB_PORT=5432
DB_NAME=runique

SQLite (dev):

DATABASE_URL=sqlite:runique.db?mode=rwc

Templates & Assets

VariableDefaultDescription
TEMPLATES_DIRtemplatesTemplates directory
STATICFILES_DIRSstaticStatic assets directory
MEDIA_ROOTmediaMedia directory (uploads)
TEMPLATES_DIR=templates
STATICFILES_DIRS=static:demo-app/static
MEDIA_ROOT=uploads

Security

VariableDefaultDescription
SECRETE_KEY(required)CSRF secret key (⚠️ CHANGE IN PROD!)
ALLOWED_HOSTS*Allowed hosts (comma-separated)

ALLOWED_HOSTS patterns:

  • localhost — exact match
  • * — wildcard all hosts (DANGEROUS in production!)
  • .example.com — matches example.com and *.example.com
SECRETE_KEY=your_secret_key_change_this_in_production
ALLOWED_HOSTS=localhost,127.0.0.1,example.com,.api.example.com

Complete .env file

# ============================================================================
# SERVER CONFIGURATION
# ============================================================================
IP_SERVER=127.0.0.1
PORT=3000
DEBUG=true

# ============================================================================
# DATABASE CONFIGURATION
# ============================================================================
DATABASE_URL=postgres://postgres:password@localhost:5432/runique
DB_ENGINE=postgres
DB_USER=postgres
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=runique

# SQLite (Development only)
# DATABASE_URL=sqlite:runique.db?mode=rwc

# ============================================================================
# TEMPLATES & STATIC FILES
# ============================================================================
TEMPLATES_DIR=templates
STATICFILES_DIRS=static
MEDIA_ROOT=media

# ============================================================================
# SECURITY
# ============================================================================
SECRETE_KEY=your_secret_key_here_change_in_production
ALLOWED_HOSTS=localhost,127.0.0.1

Generate a secret key

# Python
python3 -c "import secrets; print(secrets.token_urlsafe(32))"

# OpenSSL
openssl rand -base64 32

Environment modes

Production

DEBUG=false
PORT=443
IP_SERVER=0.0.0.0
SECRETE_KEY=<dynamically generated>
ALLOWED_HOSTS=example.com,www.example.com,.api.example.com
DATABASE_URL=postgres://user:pwd@prod-db.example.com:5432/runique

Development

DEBUG=true
PORT=3000
IP_SERVER=127.0.0.1
SECRETE_KEY=any_dev_key
ALLOWED_HOSTS=*
DATABASE_URL=sqlite:runique.db?mode=rwc

Testing

DEBUG=true
SECRETE_KEY=test_key
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=sqlite::memory: