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
Uh oh!
There was an error while loading. Please reload this page.
-
The code does not makes use of any of the environemnt variables from
.envfile. This is because one of the following reasons :getConfigfunction located inbackend/src/lib/config/env.ts. However, sincebackend/src/main.tsdoes not configuresdotenvcorrectly (dotenvneeds to have apathattribute specified to locate.env, since it is not located at the same level),backend/src/lib/config/env.tscannot locate the.env.getConfigfunction ( for example inbackend/src/db/knexfile.ts), they are usingdotnevto acess these environment variables, butdotenvin those files is either missingpathattribute 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
getConfiginbackend/src/lib/config/env.tsbut not read from.envAll the environemnt variables listed in this section are not read from the
.envfile becauseprocess.env.ENVIRONMENT_VARIABLEis not used in thegetConfigfunctionAUTH_SECRETREDIS_URLSITE_URLSMTP_HOSTSMTP_USERNAMESMTP_PASSWORDCLIENT_ID_HEROKUCLIENT_ID_VERCELCLIENT_ID_NETLIFYCLIENT_ID_GITHUBCLIENT_ID_GITLABCLIENT_ID_BITBUCKETCLIENT_SECRET_HEROKUCLIENT_SECRET_VERCELCLIENT_SECRET_NETLIFYCLIENT_SECRET_GITHUBCLIENT_SECRET_GITLABCLIENT_SECRET_BITBUCKETCLIENT_SLUG_VERCELCLIENT_ID_GOOGLE_LOGINCLIENT_SECRET_GOOGLE_LOGINCLIENT_ID_GITHUB_LOGINCLIENT_SECRET_GITHUB_LOGINCLIENT_ID_GITLAB_LOGINCLIENT_SECRET_GITLAB_LOGINCAPTCHA_SECRETPLAIN_API_KEYPLAIN_WISH_LABEL_IDSProvided by
getConfiginbackend/src/lib/config/env.tsbut values are hardcodedAll the values in this section are also provided by
getConfigbut instead of being read from the.envfile they are hardocdedSMTP_PORTPOSTHOG_HOSTPOSTHOG_PROJECT_API_KEYDeclared in
.envbut not used anywhere in the codebasePOSTGRES_PASSWORDPOSTGRES_USERPOSTGRES_DBSMTP_NAMESENTRY_DSNOther issues
DB_CONNECTION_URI: This environment variable is provided bygetConfigand is also directly used inbackend/src/db/knexfile.ts. Sincedotenvis not configured withpathattribute inbackend/src/db/knexfile.tsis unable to locate the.env. In thegetConfigfunction the value is not read from.envBeta Was this translation helpful? Give feedback.
All reactions