-
Notifications
You must be signed in to change notification settings - Fork 116
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
Using local environment variables #118
Comments
indeed i think this is the best way right now. we are working on some features to help with the API security but it wont address your usecase i think. good job on figuring out the workaround. we will definitely need better support for this. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Are there any updates? I also find a hard time making my functions use the same NODE_ENV as the rest of my Gatsby project. I would prefer not to change the variable thru netlify Admin each time I do local development. Here is the question about it on netlify forum |
Hi @azdanov, this doesn't work for me, please can you let me know where is your .env file located? Thanks Cedd |
@ceddlyburge, it took a while for me to figure out how to set it up correctly too, so I'll post how I got it working here for prosperity. You need to:
Also a gotcha I found with Don`t do
Instead, do
|
Thanks very much Tak, I owe you a favour :) |
Hi all, thanks for the explanation above. I tried to apply this to my react project, but get an error when executing the script:
Any ideas, would be appreciated! thanks Update: Please forget it, it was just the "dir" => functions missing in my script. Case Closed! |
add reference to netlify/netlify-lambda#118
Doesn't work with gatsby 3.
|
Is there a way to specify environment variables for
netlify.toml
for local development?As I understand this file is required during build stage on netlify and needs to be included inside the GitHub repository, for example. But this way it's impossible to hide any environment variables, such as API keys.
Are there any ways similar to
create-react-app
where.env.local
is used, but ignored via.gitignore
.After messing around I found a workaround by specifying a
webpack.functions.js
that picks up.env
:If this is the best way, then it could be useful mentioning this approach in the readme.
The text was updated successfully, but these errors were encountered: