0

I have used Heroku and Netlify for storing Firebase environment variables, and it seems pretty straightforward as I can go to the website and enter them manually. I was looking around Firebase and it seems a little more complicated. Where does everyone go to for setting environment variables for Firebase? Is there a sure fire way to do it on the website by just entering in the values? I'm currently messing around with create-react-app.

karel
  • 5,489
  • 46
  • 45
  • 50
seattleguy
  • 327
  • 1
  • 4
  • 11
  • Unlike Heroku - there is no way to enter/view environment variables on the website. They have to be configured using the command line. Word of warning - make sure you're following the [v1](https://stackoverflow.com/questions/50139495/how-to-get-set-firebase-cloud-functions-v1-environment-variables) format and not the outdated beta format when you're looking at examples. – JeremyW Feb 22 '19 at 13:11
  • What is a "Firebase environment variable"? I don't understand what you're trying to accomplish here. Which Firebase product are you trying to use? – Doug Stevenson Feb 22 '19 at 16:20
  • sorry that was a typo. I meant environment variables in general such as api keys for example. – seattleguy Feb 22 '19 at 17:38

1 Answers1

1

I know this is a little after the fact but you set firebase environment variables from the command line using

firebase functions:config:set someObject.key1="www.api.com" someObject.key2="someOtherKey"

then access them using the firebase-functions npm package

var api = functions.config().someObject.key1;

I will happily admit it's nowhere near as simple as the way Heroku/Amazon do it where they just append variables to process.ENV and it can all be configured from a UI

Ash Hogarth
  • 497
  • 2
  • 6
  • 18
  • Hey, I know this is a long time after your post but I'm still really flummoxed. Am I right in thinking we can no longer simply use ```REACT_APP_FIREBASE_KEY=xxx``` in our .env file? I've been trying, like with Netlify, but my hosted app seems to work for a short time and then stop working. – JimmyTheCode Jan 26 '21 at 09:23