Firebase functions:config:set silently discarding values?

Viewed 344

Just tried this:

firebase functions:config:set  firebase.webapikey="XXXXX"

Error: Cannot set to reserved namespace firebase

Error is clear. So I tried this:

firebase functions:config:set firebaseapis.web="XXXX"
āœ”  Functions config updated.

Please deploy your functions for the change to take effect by running firebase deploy --only functions

Good, no errors. However:

carlos@carlos-linux-dev:~/firestore_experiments$ firebase functions:config:get |grep firebase
carlos@carlos-linux-dev:~/firestore_experiments$ 

So that key wasn't actually stored. However if change it to something else:

dev:~/firestore_experiments$firebase functions:config:set pithole.web="XXXX"
āœ”  Functions config updated.

Please deploy your functions for the change to take effect by running firebase deploy --only functions

carlos@carlos-linux-dev:~/firestore_experiments$ firebase functions:config:get |grep pithole
"pithole": {

I couldn't find any reference in the documentation about this, seems like a bug... is this actually intended behavior?

And more to the point, is the Web API available automatically to a Firebase project oo is it something that indeed needs to be copy/pasted from the console?

2 Answers

There is an internal bug that prevents keeps config param names starting with the string "firebase" from working correctly, as you had in your second sample that doesn't work. (firebaseapi.web still starts with "firebase"). Start it with any other 8 characters, and you should be OK.

And more to the point, is the Web API available automatically to a Firebase project or is it something that indeed needs to be copy/pasted from the console?

I've been looking for a way to achieve this and have so far had no success.

There is an environment variable available to cloud functions at process.env.FIREBASE_CONFIG but this does not contain the API key, only the following properties:

{
  "projectId":"[project-name]",
  "databaseURL":"https://[project-name].firebaseio.com",
  "storageBucket":"[project-name].appspot.com",
  "locationId":"europe-west"
}
Related