【发布时间】:2020-07-01 11:07:08
【问题描述】:
为了方便测试 https 可调用函数,我想以可以评估在线数据库的方式运行函数模拟器。
模拟器的启动方式我认为是这样的:
"GOOGLE_APPLICATION_CREDENTIALS=\"/path/to/credentials.json\" firebase emulators:start --only functions"
现在我仍然需要将我的应用程序中的 firebase 函数配置指向模拟器的主机/端口。
有没有办法做到这一点?
对于firestore,您可以执行以下操作:
const db = firebaseApp.firestore();
if (window.location.hostname === "localhost") {
console.log("localhost detected!");
db.settings({
host: "localhost:8080",
ssl: false
});
}
是否有类似的方法来配置 firebase 函数以指向模拟器?
我知道你可以通过 functions-shell 测试函数,但我觉得不是很方便。我想将我的应用与 firestore 中已有的数据一起使用。
【问题讨论】:
标签: firebase google-cloud-firestore google-cloud-functions firebase-cli