Skip to main content

.env Reference

A .env file is a special file that is used to store configuration settings for SnailyCAD.

Reference

POSTGRES_PASSWORD

The password to the PostgreSQL database.

warning

This password must not contain the following characters: #, $, ", '.

POSTGRES_USER

The username to the PostgreSQL database.

POSTGRES_DB

The database name. We recommend: snaily-cadv4

DB_HOST

The database host URL. Most likely localhost.

note

Only when using Docker installation: change this to postgres.

DB_PORT

The port to the database.

note

Only when using Docker installation: keep this as 5432

JWT_SECRET

This is a random value to keep the CAD secured.

warning

This token must not contain the following characters: #, $, ", '.

CORS_ORIGIN_URL & NEXT_PUBLIC_CLIENT_URL

The URL/IP to where the CAD is hosted at, see examples below.

tip

In support, this will be called the client.

Valid Examples:

  • https://cad.example.com - subdomain
  • https://mycad.com - Top level domain
  • http://192.168.0.190:3000 - LAN IP-address
  • http://83.39.20.30:3000 - WAN IP-address

Invalid Examples:

  • localhost - will simply not work.
  • cad.example.com - missing https:// or http://.
  • http://192.168.x.x:3000 - default URL, will not work.

NEXT_PUBLIC_PROD_ORIGIN

The URL/IP to where the API is hosted at (/v1 is required.), see examples below.

tip

In support, this will be called the API.

Valid Examples:

  • https://cad-api.example.com/v1 - subdomain
  • http://192.168.0.190:8080/v1 - LAN IP-address
  • http://83.39.20.30:8080/v1 - WAN IP-address

Invalid Examples:

  • https://cad-api.example.com - missing /v1
  • cad-api.example.com - missing https:// or http://.
  • localhost - will simply not work.
  • http://192.168.x.x:8080/v1 - default URL, will not work.

PORT_API

The port where the API should run on.

tip

Default: 8080

PORT_API

The port where the API should run on.
Default: 8080

PORT_CLIENT

The port where the client should run on.
Default: 3000

ENCRYPTION_TOKEN

Used to generate encrypted values.
Generate one here

warning

This token must be exactly 32 characters long.

DOMAIN

The domain you might be using. (Optional, however, recommended)

WARNING
  1. You may only set this when using a domain name.
  2. This must be the TLD of the domain. (e.g.: example.com or mycommunity.com)
tip

Valid Examples:

  • example.com
  • example.com:3000 - a port can only be used when using a domain without SSL (https).

Invalid Examples:

  • cad.example.com - subdomain cannot be used. must be top level domain
  • 192.38.33.29 - an IP is not a domain

SECURE_COOKIES_FOR_IFRAME

Only enable when uterly required. (This may not work all the time; work-in-progress.)

Example .env file

# Documentation can be found at: https://docs.snailycad.org/docs/guides/env/reference

# This is the password to the postgress database.
POSTGRES_PASSWORD="Y8CURkTv"

# This is the username to the postgress database.
POSTGRES_USER="postgres"

# The database host - Set as 'postgres' when using docker compose
DB_HOST="localhost"

# The database port - keep port as '5432' when using docker compose
DB_PORT="5432"

# The database name.
POSTGRES_DB="snaily-cad-v4"

# This is a random value to keep the CAD's cookies secured. Make sure to change this!
JWT_SECRET="GxuPM0XmlxvCDX0QfZeqLSo0uvNm3FsEZN56JRZYNSU="

# string of 32 characters long. Make sure to change this!
# Generate one at: https://codebeautify.org/generate-random-string
ENCRYPTION_TOKEN="BOqZR1ycU0zl6vEo64JgZB8BPtjcR7"

# This is the URL/IP to your site where the CAD is hosted.
# -> e.g. https://cad.mysite.com or http://99.99.00.190:3000
CORS_ORIGIN_URL="https://cad.example.com"

# The URL/IP to where the API is hosted.
# -> e.g. https://cad-api.mysite.com/v1 or http://99.99.00.190:8080/v1
NEXT_PUBLIC_PROD_ORIGIN="https://cad-api.example.com/v1"

# only enter this value if you're using a domain!
# domain should only be the domain, NOT including sub-domains
# example: `DOMAIN="example.com"`
DOMAIN="example.com"

# "true" or "false"
# Can only be enabled when having valid SSL (https) and a domain.
SECURE_COOKIES_FOR_IFRAME="false"

# The port of which the API will run on. Default: 8080
# When using Docker, make sure to change this in the `production.docker-compose.yml` file too.
PORT_API=8080

# The port of which the client will run on. Default: 3000
PORT_CLIENT=3000

# Do not change this.
NODE_ENV="production"

# Do not change this, unless you know what you're doing!
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:${DB_PORT}/${POSTGRES_DB}?sslmode=prefer

Was this page helpful?