DEV Community

Discussion on: How Can I Access Environment Variables in My Static Website?

Collapse
 
recursivefaults profile image
Ryan Latta

There are some good answers here but I'll give a more old-school way this used to go down.

Your code would have something like ${env.api_key} in it.

Your build pipeline searches for those and replaces it with the correct value so your build artifact has the apikey built in, but what you check in does not.

I'm not sure the javascript way to facilitate that, but I'd be willing to bet someone already wrote something to do this.