4

I have a react-native mobile app that uses the firebase web SDK to init firebase:

import firebase from 'firebase';

firebase.initializeApp({
  apiKey: ...,
  authDomain: ...,
  projectId: ...,
  databaseURL: ...,
  hostingURL: ...,
  storageBucket: ...,
});

And then I can call the cloud functions like this:

firebase.functions().httpsCallable('someFunction')(params);

My Goal

What I want is to config my client to connect to the local served cloud functions that is running after I do $ firebase serve in my command line:

✔  functions: inviteNonuserToCircle: http://localhost:5000/mvp-finli-remote-local/us-central1/inviteNonuserToCircle
✔  functions: inviteUserToCircle: http://localhost:5000/mvp-finli-remote-local/us-central1/inviteUserToCircle

I want to do this so that I can test and iterate my functions quickly in my local without deploying them.

P.S. I've managed to use Postman to test the local running functions with the URLs provided by $ firebase serve, but I'd like to test them directly with my client app.

czphilip
  • 897
  • 1
  • 8
  • 18

1 Answers1

4

If you are still looking for a solution, there has been an update on the client side SDK, here's the relevant issue: Testing https.onCall with locally running serve

In short, from version 5.2.0 you can use the useFunctionsEmulator function to select a different URL for your cloud functions. Eg.:

const app = firebase.initializeApp({ ... });
app.functions().useFunctionsEmulator('http://localhost:5000');
Endanke
  • 867
  • 13
  • 24
  • or using `http://0.0.0.0` to have access over *LAN*. [firebase cli serve cant access the project from different device - Stack Overflow](https://stackoverflow.com/questions/48769168/firebase-cli-serve-cant-access-the-project-from-different-device?rq=1) – eapo Nov 27 '19 at 01:25