Version: 2.0.0 (latest)

Ship to Production

You are reading the documentation for version 2 of FoalTS. Instructions for upgrading to this version are available here. The old documentation can be found here.

1. Set the Node.JS environment to production#

Set the NODE_ENV environment variable to production.

NODE_ENV=production npm run start

2. Use HTTPS#

You must use HTTPS to prevent man-in-the-middle attacks. Otherwise, your credentials and authentication tokens will appear in clear on the network.

If you use cookies, make sure to let them only be sent to the server when the request is made using SSL. You can do such thing with the cookie secure directive.

config/production.yml (example)

// If you use sessions
secure: true
// If you use JWT
secure: true

3. Generate Different Secrets#

Use different secrets for your production environment (JWT, etc). Specify them using environment variables or a .env file.

.env (example)


You can generate 256-bit secrets encoded in base64 with the following command:

foal createsecret

4. Database Credentials & Migrations#

Use different credentials for your production database. Specify them using environment variables or a .env file.

If you use database migrations, run them on your production server with the following command:

npm run migrations