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.
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.
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?