When you update cloud function environment variables, the config values are not accessible when using the local node.js emulator.
On a project with no environment config variables:
firebase functions:config:set x=true
firebase functions:config:get
(shows the new value)firebase deploy --only functions
functions.config{}
{}
(empty object)There is no mention in the environment config docs but I am assuming it is possible to use the same environment config locally (or a local alternative)?
The Firebase Local Emulator Suite is a set of advanced tools for developers looking to build and test apps locally using Cloud Firestore, Realtime Database, Cloud Storage, Authentication, Cloud Functions, Pub/Sub, Firebase Hosting and Firebase Extensions.
The answer was in the local emulator documentation.
Note: You can retrieve your production custom configuration variables when emulating functions. However, be cautious when using production config values in local testing of API calls, emails, etc.
To use config variables, run the following command in the functions directory before running firebase serve.
MacOS
firebase functions:config:get > .runtimeconfig.json
Windows
firebase functions:config:get | ac .runtimeconfig.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With