fool
September 6, 2019, 10:55pm
2
Hi Roger,
Have you seen this article?
Last reviewed: August 2023
The preferred way to use environment variables in Netlify is to set them in our environment - be that in the Environment Variables settings UI (on the site’s “Build & Deploy settings” page), or via netlify.toml . You’ll want to choose the right pattern to meet your needs. Setting variables in our UI may be considered a bit more secure, since only people with access to the Netlify admin UI for your site can see them, rather than “anyone who can clone your repo!”.
Thes…
It describes how to successfully USE the environment variable; TL;DR it’s usable at BUILD TIME ONLY, and during your build you’d put it into your static pages, since it isn’t available at BROWSE TIME for interpolation.
If you need to hide the API key, consider a function such as this one to “proxy” to that API with that key: https://github.com/netlify/code-examples/tree/master/function_examples/token-hider
1 Like