Skip to content
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

Allow for a dotenv per environment #740

Open
elpablete opened this issue Dec 29, 2020 · 5 comments · May be fixed by #1149
Open

Allow for a dotenv per environment #740

elpablete opened this issue Dec 29, 2020 · 5 comments · May be fixed by #1149

Comments

@elpablete
Copy link

Many times I find myself with an .env file per environment (local.env, test.env, prod.env), that way I can use the same names on my code and still not commit any values to repos. Right now there is no way to do so, but a more powerful feature would be to allow a different .env file to be defined in each environment (even in $shared)

@philwrenn
Copy link

Something like this would be helpful for me too. I'm not currently using different .env files, but I would like to store a few .http files in a folder. That would mean they wouldn't be in the project root with my .env file.

If we could provide a relative path to a specific .env file, then @elpablete and my issue would possibly both be addressed.

@FDiskas
Copy link

FDiskas commented Mar 31, 2021

usually such files are named like so

.env
.env.local
.env.production

@wekempf
Copy link

wekempf commented Nov 5, 2021

I'd love this as well, but until (if?) this is done, there's a workaround. In your settings.json you define your environments like this.

"dev":
{
    "secret": "devSecret"
},
"prod":
{
    "secret": "prodSecret"
}

In your .env file you'd then have this.

devSecret=xyzzy
prodSecret=plough

Finally in your http file you'd have this.

@secret = {{$dotenv %secret}}

A little more complicated to setup, but this allows the values you use to change when you change the environment. This is untested and may need some tweaking, but the idea should work.

@monisnap-paul
Copy link

monisnap-paul commented Mar 11, 2022

Would it be possible to try to load first .env.{{environmentName}} with environmentName the name of the currentEnvironment (e.g. .env.local, env.dev, ...)
and if this file does exist, load the .env file in $dotenv variable ?

@nicksmider nicksmider linked a pull request May 1, 2023 that will close this issue
@Nilegfx
Copy link

Nilegfx commented Jun 21, 2023

I would love to have this feature too!
Maintainers, could you please review and merge the PR mentioned here?

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 a pull request may close this issue.

6 participants