Environment variables
https://firebase.google.com/docs/functions/config-env?gen=2nd#env-variables
.env
OPENAI_API_KEY=xxx
or
firebase functions:secrets:set OPENAI_API_KEY
Read from Env
read from inside the cloud function
process.env
read from secret
onRequest(
{ secrets: ["OPENAI_API_KEY"] },
(req, res) => {
process.env
deployment
at deployment, firebase sends the .env file to firebase servers
v1
Tell firebase to save a token/key on our behalf so that we can access it by reference in code, without writing the actual key in code and in git as a result.
firebase functions:config:set sendgrid.key="...." sendgrid.template="TEMP"
Read from Env
Firebase exposes the tokens/keys in an object we get through the config() method.
const API_KEY = functions.config().myKey