-
Notifications
You must be signed in to change notification settings - Fork 358
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
Netlify Dev: Add support for .env files #714
Conversation
looks good but needs docs and tests. got to start having a habit of adding these alongside features or it just never gets done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I can't speak to the implementation, I think this is what is so desperately desired by our users. Best way to be sure it suits their needs is to let them test it in prod :)
So this seems to work for new variables in .env, but if I have an existing variable in netlify.com the "remote" variable overrides my local .env. This seems backwards to me. The whole point of a .env file is to use "dev" api key for local development and a production key in actual production. Am I missing something? |
@unclejustin I can confirm this behavior for Netlify Function. The cause for this is that |
Being discussed here: #734 |
No matter what I do - I cannot access any variables from my .env file in my functions.
Though On a side note, this is the third bothersome quirk with I'm on |
@oles Can you please share an example project with this problem! |
@RaeesBhatti Sure - I'll get to it tomorrow 👍 |
@RaeesBhatti Here you go: https://github.com/oles/netlify-functions-env-example Just run Then open They should be the values from the .env file, as accessed in the function with |
🍻 Cheers for the transparency @RaeesBhatti ! |
@RaeesBhatti Perfect! Thank you! |
A fix for this has been released in |
This only listens for for variables in |
Yeah this is confusing as Gatsby uses the above env files, not just |
yes, I was also confused by that so I created #924 hope that helps |
- Summary
Allows users to use
.env
files for their site generators and Netlify functions written in JS, when usingnetlify dev
.Fixes: #457
Fixes: #444
Fixes: #474
Fixes: #405
- Test plan
.env
file to your function directory withSOMETHING=true
and see if it is accessible in function usingprocess.env
while running throughnetlify dev
.env
file to the root of your project and see if it is available to your site framework (etc. React etc.) when running throughnetlify dev
- Description for the changelog
dotenv
package to parse.env
file if exists and set the env variables to newly spawned site server process.netlify dev
lambda-local
to serve JS functions and pass path to function local.env
file as parameter when executing- A picture of a cute animal (not mandatory but encouraged)
🙈