I have an express app that I want to run locally as a standalone server in my machine however, when deploying it to firebase cloud functions I need to set it as a cloud function.
Is there a reliable way to know in which environment the app is running without manually setting env variables or what is the best practice?
eg:
if(isRunningInFirebase()){
exports.myFun=functions.https.onRequest(app)
} else app.listen(3030)
Firebase now sets the FUNCTIONS_EMULATOR
environment variable when running the emulator:
if (process.env.FUNCTIONS_EMULATOR === 'true') {
functions are on localhost
} else {
functions are on Firebase
}
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