Search code examples
firebasegoogle-cloud-firestorelocalhostgoogle-cloud-functionsfirebase-cli

How to run firebase emulators for local development with functions, triggers on remote db?


I'm building a firebase API with cloud functions and want to reach my production Database for local testing. My problem :


When I launch my two firebase emulator (functions and firestore) with

firebase emulators:start 

1- My custom API endpoints run on http://localhost:5001 (this works)

2- My triggers reaches a local dababase on http://localhost:8080 whereas I didn't set FIRESTORE_EMULATOR_HOST=localhost:8080 (I want to reach my production database)

OR

When I launch only my "functions emulator" with

firebase emulators:start --only function

...but my triggers are not reached, probably because of this warning

i  functions[userOnCreate]: function ignored because the firestore emulator does not exist or is not running.

On the other side I'm building a reactjs App also with firebase running on localhost:3000

I call my local API from this app with firebase SDK. To reach my emulator, I add the line :

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

Solution

  • The local emulators don't work with actual cloud-hosted instances of databases. Everything must be local.

    You are always free to file a feature request.