Using locally emulated https.onCall functions in a locally hosted web application

570 views
Skip to first unread message

David Stephenson

unread,
Jun 25, 2018, 10:58:13 AM6/25/18
to Firebase Google Group

I am writing a Firebase application in JavaScript. I am using Firebase Cloud Functions to implement a server that receives requests for my page routes hosted by Firebase hosting and returns rendered HTML with the https.onRequest method and Express. I am also using Cloud Functions to handle server-side actions with https.onCall methods.


I develop locally using the firebase serve command. When developing locally, my client seems ignores my local onCall functions, instead calling the route for the deployed onCall functions. I am forced to deploy my onCall functions in order to see changes locally. If I do not deploy each change, my local app will not show any changes to onCall functions. This happens whether I run


firebase serve


or


firebase serve --only=hosting,functions


When run my app locally with firebase serve, the pages are generally hosted at localhost:5000, with my functions locally emulated at localhost:5001. If I call a cloud function on one of these pages, like


firebase.functions().httpsCallable('functionName')


and check the Network panel in my developer tools, I can see the Request URL is


https://us-central1-<app-name>.cloudfunctions.net/<functionName>


instead of


localhost:5001/<app-name>/us-central1/<functionName>


where my terminal says the local function is available.


Have I configured something incorrectly? How can I get my locally hosted app to use my locally emulated onCall cloud functions?

Michael Bleigh

unread,
Jun 25, 2018, 11:32:14 AM6/25/18
to Firebase Google Group
We don't yet support calling locally emulated functions, but hope to support it soon. Thanks!

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/0bdd928b-7e42-4fd3-b4dc-57d138f55b1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Toufeeq

unread,
Feb 27, 2019, 11:00:07 AM2/27/19
to Firebase Google Group
Just add this line before calling https.callable('functionName');

firebase.functions().useFunctionsEmulator('http://localhost:5001');

This will call the locally emulated function instead of hosted cloud function.
Reply all
Reply to author
Forward
0 new messages