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

限于喜欢 提交于 2021-01-29 09:14:48

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/64092806/is-it-possible-to-connect-a-local-functions-emulator-to-a-non-local-firebase-rea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!