问题
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