【问题标题】:Firestore web client dont point on emulator - Throwing PERMISSION_DENIED: Missing or insufficient permissionsFirestore Web 客户端不指向模拟器 - 抛出 PERMISSION_DENIED:缺少权限或权限不足
【发布时间】:2020-07-10 03:22:13
【问题描述】:

尝试做一些基本的firestore req,但尽管当地规则允许一切,但我得到了权限错误:

PERMISSION_DENIED: Missing or insufficient permissions.

事实证明网络客户端同时使用在线商店和规则(不是本地模拟的),尽管我以这种方式放置配置:

const firebaseConfig = {
  apiKey:  ///,
  authDomain: "http://localhost:3000",
  databaseURL: "http://localhost:8080",
  projectId: ///,
  storageBucket: "http://localhost:8080",
  messagingSenderId: ///,
  appId: ///,
  measurementId: ///
};

我应该如何配置 Web 客户端以使其指向本地模拟 Firestore?

【问题讨论】:

    标签: firebase google-cloud-firestore firebase-cli


    【解决方案1】:

    发现 this tutorial 正在以这种方式配置 Firestore Web 客户端:

      const db = firebaseApp.firestore();
    
      if (window.location.hostname === "localhost") {
        console.log("localhost detected!");
        db.settings({
          host: "localhost:8080",
          ssl: false
        });
      }
    

    我的网络客户端现在指向本地 Firestore。 (虽然在文档中找不到参考。)

    【讨论】:

      猜你喜欢
      • 2019-01-06
      • 2018-04-25
      • 2020-09-06
      • 2019-02-26
      • 2020-09-25
      • 2019-01-21
      • 2022-01-25
      • 2019-05-05
      相关资源
      最近更新 更多