Ad

Can We Use A Boolean As Env Variable In Firebase Functions

I'm trying to make an app on Firebase functions (a Puppeteer app) and I do have the following in a .json file. It is working great locally.

"custom": {
  "following_training": false,
  "worked": false
}

But when I do push it remotely and try to setup my code with firebase functions:config:set app="$(cat .env-production.json)" (to avoid typing a long .json config env variable string essentially), I do have the following warning: HTTP Error: 400, Invalid value at 'variable.text' (TYPE_STRING), false

So yeah, it's basically telling me to only send that kind of json:

"custom": {
  "following_training": "false",
  "worked": "false"
}

Then, it is working remotely if I do add that to-bool package to actually check inside of the code if toBool(local_vars.app.custom.worked) == false...

Isn't there a cleaner way to do it...? In the firebase config-env documentation, there is actually no example about a boolean field.

I do get the expected stuff when typing firebase functions:config:get but something strange too is that I do not have any variables in the Google Cloud Platform function's dashboard (I get refreshed code, Puppeteer's option settings, and so on..).

Not sure if it's anyhow related.

The env vars may just be used by Firebase and do not need to be sent to the GCP.

EDIT: working great, not a Firebase issue here.

Ad

Answer

Environment variables are only string types.

There's no typing (other than string) of shell|environment variables.

You should set a boolean in your code based on the value (or non-value) of the (environment value) string.

Ad
source: stackoverflow.com
Ad