I am using Google Cloud Functions Emulator for debugging locally my Firebase functions. Firebase recommend to use functions.https.onCall
functions instead of functions.https.onRequest
for avoid using http calls directly. Instead Firebase recommend to use Firebase Functions SDK for call such functions from code. For functions.https.onRequest
I used http-trigger
flag but how can I debug onCall
functions ?
I found a way to run 'onCall' cloud functions locally and call them from a local client. I still haven't figured out how to attach a debugger but at least I can iterate faster and use console.log statements.
Use firebase serve
to host the functions. Even though these are supposed to be for http requests I found that the the firebase clients have a property to override the host name for onCall
functions. This takes care of authentication and passing in the right data and context objects for you.
From Terminal in the root of your firebase project folder:
firebase serve
You should get a successful result in the terminal window. Take the hostname and port number:
✔ functions: helloWorld: http://localhost:5000/your-project-name/us-central1/helloWorld
iOS client:
Functions.functions().useFunctionsEmulator(origin: "http://localhost:5000")
NOTE: you have to disable App Transport Security in iOS for this to work
NOTE: other clients probably have the same API.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.