Why is the codebase not using environemnt variables from .env
files
#2210
Unanswered
divyanshchahar
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The .env file is pased via Zod here https://github.com/Infisical/infisical/blob/main/backend/src/lib/config/env.ts#L167 And it is used throughout the app via https://github.com/Infisical/infisical/blob/main/backend/src/lib/config/env.ts#L164 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The code does not makes use of any of the environemnt variables from
.env
file. This is because one of the following reasons :getConfig
function located inbackend/src/lib/config/env.ts
. However, sincebackend/src/main.ts
does not configuresdotenv
correctly (dotenv
needs to have apath
attribute specified to locate.env
, since it is not located at the same level),backend/src/lib/config/env.ts
cannot locate the.env
.getConfig
function ( for example inbackend/src/db/knexfile.ts
), they are usingdotnev
to acess these environment variables, butdotenv
in those files is either missingpath
attribute or the path resolution cannot happen properly.Below is a detailed description for every environment variable and why they are essentially unused in the code base
Provided by
getConfig
inbackend/src/lib/config/env.ts
but not read from.env
All the environemnt variables listed in this section are not read from the
.env
file becauseprocess.env.ENVIRONMENT_VARIABLE
is not used in thegetConfig
functionAUTH_SECRET
REDIS_URL
SITE_URL
SMTP_HOST
SMTP_USERNAME
SMTP_PASSWORD
CLIENT_ID_HEROKU
CLIENT_ID_VERCEL
CLIENT_ID_NETLIFY
CLIENT_ID_GITHUB
CLIENT_ID_GITLAB
CLIENT_ID_BITBUCKET
CLIENT_SECRET_HEROKU
CLIENT_SECRET_VERCEL
CLIENT_SECRET_NETLIFY
CLIENT_SECRET_GITHUB
CLIENT_SECRET_GITLAB
CLIENT_SECRET_BITBUCKET
CLIENT_SLUG_VERCEL
CLIENT_ID_GOOGLE_LOGIN
CLIENT_SECRET_GOOGLE_LOGIN
CLIENT_ID_GITHUB_LOGIN
CLIENT_SECRET_GITHUB_LOGIN
CLIENT_ID_GITLAB_LOGIN
CLIENT_SECRET_GITLAB_LOGIN
CAPTCHA_SECRET
PLAIN_API_KEY
PLAIN_WISH_LABEL_IDS
Provided by
getConfig
inbackend/src/lib/config/env.ts
but values are hardcodedAll the values in this section are also provided by
getConfig
but instead of being read from the.env
file they are hardocdedSMTP_PORT
POSTHOG_HOST
POSTHOG_PROJECT_API_KEY
Declared in
.env
but not used anywhere in the codebasePOSTGRES_PASSWORD
POSTGRES_USER
POSTGRES_DB
SMTP_NAME
SENTRY_DSN
Other issues
DB_CONNECTION_URI
: This environment variable is provided bygetConfig
and is also directly used inbackend/src/db/knexfile.ts
. Sincedotenv
is not configured withpath
attribute inbackend/src/db/knexfile.ts
is unable to locate the.env
. In thegetConfig
function the value is not read from.env
Beta Was this translation helpful? Give feedback.
All reactions