Skip to content

Environment variables

Nima Dekhli edited this page Apr 9, 2024 · 10 revisions

Introduction

Some environment variables must be set before using the app. You can store them in an .env file with the following format :

SOME_KEY=some_value

When using the docker-compose file to deploy the app in local, there is no need to create environment variable!

The environment variables files must never be tracked by git !

Backend

File location

The file must be on the same directory as the settings.py file, like neurona/api/neurona/.env

Required variables

Passkey relaying party ID

key : PASSKEY_RP_ID

default value : None

The value must represent the relying party ID.

Passkey origin

key : PASSKEY_ORIGIN

default value : None

The origin must match the passkey authentication requests origin

Allowed hosts

key : ALLOWED_HOSTS

default value : None

The variable must match the API server possible addresses. Each host is separated with a comma. If there is only one host, the value must end with a comma, like : ALLOWED_HOST=localhost,

CORS allowed origins

key : CORS_ALLOWED_ORIGINS

default value : None

The variable must match the frontend server possible origins, including protocol and port. Each origin is separated with a comma. If there is only one origin, the value must end with a comma, like : CORS_ALLOWED_ORIGINS=http://localhost:3000,

Debug mode (Optional)

If you want to see debug logs when making requests to the API, set the debug mode to True :

key : DEBUG

default value : False

Database parameters (Optional)

If you don't want to use SQLite, you can specify the parameters to use to connect to another database, for example PostGreSQL. You'll need to specify the following variables (in parenthesis, you'll find the parameters to use with the given docker-compose file).

  • DATABASE_ENGINE (django.db.backends.postgresql)
  • DATABASE_HOST (neurona_db_service)
  • DATABASE_PORT (5432)
  • DATABASE_NAME (neurona)
  • DATABASE_USER (neurona)
  • DATABASE_PASSWORD (password)

Example file

PASSKEY_RP_ID=localhost
PASSKEY_ORIGIN=localhost:3000
ALLOWED_HOSTS=localhost,
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
DEBUG=True

Frontend

File location

The file must be located in the same directory as the package.json file, like neurona/frontend/.env

Required variables

API host

key : VITE_API_URL

default value : http://localhost:8000/api

The value represents the API URL.

File example

VITE_API_URL=http://localhost:8000/api