這部分
const serviceAccount = require('./firestore-reactdb-027d52fa212f.json');
導致錯誤:
Module not found: Error: Can't resolve './firestore-reactdb-027d52fa212f.json' in (...)
我從 Cloud Platform Console 中的 IAM & admin > Service accounts 下載了 json 檔案(按照“在您自己的服務器上初始化”下的說明)。我還嘗試從 Firebase 中的控制臺下載憑據(專案設定-> 服務帳戶-> 生成新的私鑰)。
PS:它在一個反應??應用程式中
uj5u.com熱心網友回復:
制作自己的服務時需要這些憑據。React 應用程式不是服務,請閱讀服務是什么。如果您想在 react 應用程式中使用 firebase,則不需要這些秘密。您需要 firebase 配置物件,您無需擔心共享它。這個配置物件對于 firebase 知道他可以在哪里發送請求等是必需的。
具有 Firebase 配置的示例物件。
const firebaseConfig = {
apiKey: "...",
authDomain: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "...",
measurementId: "..."
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/412210.html
標籤:
