是否可以将本地功能仿真器连接到非本地Firebase实时数据库? [英] Is it possible to connect a local Functions emulator to a non-local Firebase Realtime Database?
问题描述
由于使用实时数据库仿真器在Flutter中进行开发而出现的问题(请参见
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.
根据此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.
推荐答案
不可能让本地Cloud Functions仿真器响应(或触发")生产数据库中的事件.您必须部署功能,以便它们执行以响应云托管数据库中的更改.本地功能仿真器仅响应本地仿真数据库中的更改.
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.
这篇关于是否可以将本地功能仿真器连接到非本地Firebase实时数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!