.env file in the root directory of your installation.
Required Variables
These variables must be configured for SnailyCAD to function properly.Database Configuration
The password for your PostgreSQL database.
The username for your PostgreSQL database.
The database name for your SnailyCAD installation.
The database host address.
- Docker install:
"postgres" - Standalone install:
"localhost"(or another IP)
The database port.
- Docker install:
"5432" - Standalone install: port to your PostgreSQL DB (default:
"5432")
The complete database connection URL. This is automatically constructed from other database variables.
Security Configuration
A random string of characters used to keep the CAD’s cookies secured.
A string of 32 characters long used for encryption. Generate one at CodeBeautify.
URL Configuration
The URL/IP to your site where the CAD is hosted. This is used for CORS (Cross-Origin Resource Sharing) configuration.Examples:
https://cad.mysite.comhttp://99.99.00.190:3000*(allow all origins - not recommended for production)
The URL/IP to your site where the CAD client is hosted.Examples:
https://cad.mysite.comhttp://99.99.00.190:3000
The URL/IP to where the API is hosted.Examples:
https://cad-api.mysite.com/v1http://99.99.00.190:8080/v1
Must include the
/v1 suffixPort Configuration
The port on which the API will run.
The port on which the client will run.
Environment
The Node.js environment mode.
Optional Variables
These variables are optional and enable additional features when configured.Domain and Security
Your domain name. Only enter this value if you’re using a domain!Example:
Domain should only be the domain, NOT including sub-domains
DOMAIN="example.com"Enable secure cookies for iframe embedding.
Discord Integration
Your Discord bot token for Discord integration features.See the Discord Integration guide for setup instructions.
Your Discord application client ID for Discord OAuth authentication.
Your Discord application client secret for Discord OAuth authentication.
Your Discord server (guild) ID. Supports multiple servers separated by commas.Example:
DISCORD_SERVER_ID="123456789,987654321"The name displayed in Discord for the CAD connection metadata.
Steam Integration
Your Steam API key for Steam authentication.Obtain a Steam API key from Steam’s developer portal.
Google reCAPTCHA
Your Google reCAPTCHA secret key for bot protection on registration and login.Get your reCAPTCHA keys from Google reCAPTCHA.
Advanced Options
Enable this if running SnailyCAD as the root user (not recommended).This adds the
--no-sandbox flag to Chromium-based operations.Configuration Examples
Docker Installation
.env
Standalone Installation
.env
Security Best Practices
- Never commit your
.envfile to version control - Use strong, random values for
JWT_SECRETandENCRYPTION_TOKEN - Keep your database credentials secure and use strong passwords
- Use HTTPS in production with a valid SSL certificate
- Restrict CORS origins - avoid using
*in production - Regularly rotate secrets especially after team member changes
Troubleshooting
Connection Issues
If you’re experiencing connection issues:- Verify all URLs are correct and accessible
- Check that ports are not blocked by firewalls
- Ensure database is running and accessible
- Verify CORS_ORIGIN_URL matches your client URL
Database Connection Errors
If database connection fails:- Verify database credentials are correct
- Ensure PostgreSQL is running
- Check DB_HOST and DB_PORT are correct
- Test connection with
psqlor another database client
Docker-Specific Issues
For Docker installations:- Use
DB_HOST="postgres"not"localhost" - Ensure ports in
production.docker-compose.ymlmatch your.env - Restart containers after changing
.envvalues