I'm using http cloud functions to listen for a request and then return a simple message.
I'm developing cloud functions locally using:
firebase serve --only functions
I've setup some custom environment variables using
firebase functions:config:set
Accessing the custom config variables using the below code works fine when the project is deployed
functions.config()
but it does not work when developing locally. When the function is triggered by hitting: http://localhost:5002/my-project-name/us-central1/functionName I can't access the custom config variables. when using functions.config() locally, I can see the default config, just not my custom config variables
Is there an alternate solution or best practice for environment variables when working locally?
Best Answer
As of now, you have to manually create a
.runtimeconfig.json
file inside your functions directory by running this command. Then run the serve command.If you are using Windows Powershell, replace the above with:
You can learn more in https://firebase.google.com/docs/functions/local-emulator