hakondh
hakondh

Reputation: 35

Is it possible to connect a local Functions emulator to a non-local Firebase Realtime Database?

Due to problems using a Realtime Database emulator for development in Flutter (see How do I connect to my local Realtime Database emulator in my Flutter app?), I am now simply using my non-local Realtime Database for development. However, I am also using Cloud Functions, and I have created a Functions emulator.

I tried the following to connect to it, based on this StackOverflow-answer:

const functions = require("firebase-functions");
const admin = require("firebase-admin");
functions.config = () => {
  return {
    firebase: {
      databaseURL: "https://mylink.firebaseio.com/",
    },
  };
};

But the emulator is not responding to changes in the database.

So, is it even possible to connect my local Functions emulator to my non-local Realtime Database? It's kind of a weird setup, but I don't know how I am going to be able test functions otherwise.

Upvotes: 1

Views: 460

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

It's not possible to have the local Cloud Functions emulator respond to (or "trigger" on) events in a production database. You have to deploy your functions in order for them to execute in response to change in the cloud-hosted database. The local functions emulator only responds to changes in the locally emulated database.

Upvotes: 4

Related Questions