Skip to content

Update adding-custom-environment-variables.md #9529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Update adding-custom-environment-variables.md #9529

wants to merge 1 commit into from

Conversation

albingroen
Copy link

.env files should not be checked into source control (with the exclusion of .env*.local).

`.env` files **should not be** checked into source control (with the exclusion of `.env*.local`).
@facebook-github-bot
Copy link

Hi @albingroen!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@amyrlam amyrlam removed their request for review August 25, 2020 07:21
Copy link
Contributor

@petetnt petetnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @albingroen!

In the context of Create React App, the suggestion of committing .env files to the repository is correct (if not a bit controversial).

All the environment variables read from the the .env files by Create React App are prefixed with REACT_APP_ and will end up in the final bundle making them completely public. Thus committing .env files filled with REACT_APP prefixed environment variables to the version control is the best practice, as they are essentially available for everyone anyways.

.env.local* files (in CRA context) are meant for overriding the defaults and should not be committed to the repo.

Obviously the situation will get trickier if the same .env file is shared with (for example) a custom backend, in which case the file might contain private values and should not be committed to the repo.

@albingroen
Copy link
Author

Hi @albingroen!

In the context of Create React App, the suggestion of committing .env files to the repository is correct (if not a bit controversial).

All the environment variables read from the the .env files by Create React App are prefixed with REACT_APP_ and will end up in the final bundle making them completely public. Thus committing .env files filled with REACT_APP prefixed environment variables to the version control is the best practice, as they are essentially available for everyone anyways.

.env.local* files (in CRA context) are meant for overriding the defaults and should not be committed to the repo.

Obviously the situation will get trickier if the same .env file is shared with (for example) a custom backend, in which case the file might contain private values and should not be committed to the repo.

Ah I see now, this makes sense. My bad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants