How can I detect if my server environment is development or production with Firebase Cloud Functions?
I need something like this:
if(process.env.NODE_ENV === 'development'){
//DO STUFF SPECIFIC TO DEV ENVIRONMENT
}
else if(process.env.NODE_ENV === 'production'){
//DO STUFF SPECIFIC TO PRODUCTION ENVIRONMENT
}
Cloud functions in general are very cost-effective. It's difficult to compare pricing of cloud providers, but I can say that based on my experience, Firebase Cloud Functions have been ridiculously cheap.
At process.env, on firebase functions projects, there is a boolean variable called FUNCTIONS_EMULATOR, which indicates if the process is running on an emulator or on server.
this is enough to determine if environment is dev or production.
process.env.FUNCTIONS_EMULATOR === true
Obs: In some environments the variable might be a String 'true' instead of Boolean true
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