Environment Variables
Setup
This solution makes use of dotenv to easily setup environment variables on your machine that are used required for the application to run properly.
To setup your environment variables, copy and rename the env.dart.template
file to env.dart
. Then fill in the values for all the keys that you need, more on that below.
Format of the .env files
txt
KEY1=value
KEY2="value with spaces"
.env.template
Contains the keys of expected environment variables. It should not contain any sensitive information.
View contents
VITE_NMSUD_FORM_WEB_URL=http://localhost:3001
VITE_NMSUD_API_URL=http://localhost:3001
VITE_NMSUD_FORM_DATA_URL=https://data.nmsud.com
VITE_NMSUD_FORM_DOCS_URL=https://docs.nmsud.com
API_PORT=3001
API_SECRET=
DOCKER_REGISTRY=
DOCKER_TAG_NAME=
DOCKER_USERNAME=
DOCKER_PASSWORD=
XATA_API_KEY=
XATA_DB_URL=
XATA_FALLBACK_BRANCH=
DISCORD_WEBHOOK_URL=
GITHUB_ACTION_TRIGGER_ON_DECISION=false
GITHUB_ACTION_OWNER=
GITHUB_ACTION_REPO=
GITHUB_ACTION_WORKFLOW_ID=
GITHUB_ACTION_MINUTES_BETWEEN_RUN=
GITHUB_AUTH_TOKEN=
VITE_ENABLE_CAPTCHA=
VITE_HCAPTCHA_SITE_KEY=
HCAPTCHA_SECRET=
Deeper look
Keys that start with VITE_
are available on the frontend as well as the backend. If the key does not start with VITE_
it will only be available in the backend.
We may change the name of this key in the future.
Adding a new Key & Value
- Make sure that you add the new key to both the
.env
and.env.template
files. - Add a function to the configService.ts.
- Use your new environment variable with
ts
const myNewValue = getConfig().getMyNewVariable();