-
Notifications
You must be signed in to change notification settings - Fork 10
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
injecting faunadb secret as env var via .toml build command #36
Comments
Thanks for taking the time to write this up. I'll have a go at setting this up later today 👍 |
I don't think if this is necessary to be honest. If you deployed via the "Deploy to Netlify" button, this is all managed for you. Nice trick though, I'll take this with me for my other Netlify projects. |
Yeah I suppose the only real benefits in this scenario are for Cheers |
I did consider these scenarios. But I figured the more savvy users would probably figure out how to make this more "production" ready and fork off this if they really wanted to. As this repo is tightly couple to a blog tutorial i think it being a bit more opinionated will benefit beginners more. Thanks for your contribution nonetheless. As it's a pretty good tip I've pinned the issue so hopefully others will find it useful too. |
This is just a quick change to keep faunadb secret out of any files in repository; easing Netlify's github-to-netlify continuous integration.
(can do a pull request if you like as well)
Steps are below, but for reference: Netlify docs on injecting environment variables
Step 1/4 -
netlify.toml
in
netlify.toml
change
[build] command = "npm run build
to
[build] command = "sed -i s/FAUNADB_SERVER_SECRET/$FAUNADB_SERVER_SECRET/g netlify.toml && npm run build"
then also in
netlify.toml
change[template.environment] FAUNADB_SERVER_SECRET = "your FaunaDB server secret"
to
[template.environment] FAUNADB_SERVER_SECRET = ""
Step 2/4 -
.env
in local environment add a
.env
withFAUNADB_SERVER_SECRET=youractualkeyfromfauna
(i suppose this could be part of template as a file like
template.env.txt
that hasFAUNADB_SERVER_SECRET=yourkeygoeshere
and instructions to rename it, etc.)Step 3/4 -
.gitignore
in
.gitignore
add.env
to the# local env files
blockStep 4/4 -
Netlify UI
in Netlify UI go to
Settings>Build and Deploy>Environment
and a variable with key
FAUNADB_SERVER_SECRET
and value of your key from Faunadb.After that
All appears to be working as intended for both local dev,
npm start
, and for the github linked deploy.Cheers, hope it's useful.
The text was updated successfully, but these errors were encountered: