firebase serve: From a locally served app, call locally served functions

There is currently no support for local testing of callable functions like this. The team is working on a way for you to specify the URL endpoint of a callable function so that you can redirect it to a different location for testing.


UPDATE - April/2021

As of April/2021, method useFunctionsEmulator has been deprecated. It is suggested to use method useEmulator(host, port) instead.


Original post:

By default, firebase serve sends queries to CLOUD function instead of localhost, but it is possible to change it to to point to localhost.

@gregbkr found a workaround for that at this github thread.

You basically add this after firebase initialization script (firebase/init.js) in html head.

<script>
   firebase.functions().useFunctionsEmulator("http://localhost:5001");
</script>

Make sure to REMOVE it when deploying to SERVER