javascript - 火力地堡错误 : [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken

标签 javascript firebase google-cloud-firestore firebase-authentication

配置 firebase 的简单应用程序 ...

import * as firebase from "firebase/app";
import 'firebase/auth';

const app = firebase.initializeApp(FIREBASE_CONFIG);
firebase.setLogLevel('debug');
app.auth().useDeviceLanguage();
app.auth().settings.appVerificationDisabledForTesting = __DEVELOPMENT__;

然后我配置数据库

import 'firebase/firestore';
const database = app.firestore();
    database.settings({
        host: 'localhost:8080',
        ssl: true,
    });

匿名用户

const handleAuthStateChanged = (user) => {
    if (!user) {
        firebase.auth().signInAnonymously();
    }
}
app.auth().onAuthStateChanged(handleAuthStateChanged)

我试图获取一些数据

database.collection('events').doc(eventId).withConverter(eventConverter).get();

但是我收到这个错误

@firebase/firestore: Firestore (7.15.0): FirestoreClient Initializing. user= @firebase/firestore: Firestore (7.15.0): MemoryPersistence Starting transaction: Get next mutation batch @firebase/firestore: Firestore (7.15.0): MemoryPersistence Starting transaction: Allocate target @firebase/firestore: Firestore (7.15.0): MemoryPersistence Starting transaction: Execute query @firebase/firestore: Firestore (7.15.0): IndexFreeQueryEngine Using full collection scan to execute query: Query(target=Target(events/1, orderBy: [name (asc)]); limitType=F) @firebase/firestore: Firestore (7.15.0): PersistentStream close with error: FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken

@firebase/firestore: Firestore (7.15.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken

This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

FirebaseError: Failed to get document because the client is offline.


一旦我发布就可以工作

如果你去.. https://nps-event.ridermansb.dev/event/1您会看到它正在运行。

但是本地不行

这里有完整的源代码

https://github.com/Ridermansb/nps-event

最佳答案

Firebase 允许用户将其身份验证 SDK 实现到您的 sign in method .通过查看您的代码,我可以看到 Firebase 身份验证 anonymous signin这里用到了方法。方法中好像少了错误处理方法。可以引用signInAonymously method添加错误处理方法的文档以获取有关错误的更多详细信息。

关于javascript - 火力地堡错误 : [code=unknown]: Fetching auth token failed: Cannot redefine property: refreshToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62307683/

相关文章:

javascript - Firebase 云函数 Cron 更新

firebase - 与不使用通配符和 _TABLE_SUFFIX 相比,BigQuery -firebase 导出的工作方式有所不同

google-cloud-firestore - 云函数上下文参数返回未定义

javascript - 无法理解 firebase 中的 doc().get()

python - 无法在 Firebase 查询数据中传递变量

Javascript 日期函数返回错误的星期几

javascript - 使用 javascript 滚动时如何保持类事件?

javascript - 无法通过 Ajax 从文件 PHP 调用检查 session

javascript - 在我的例子中,foreach 中的 Mongoose promise 失败了

ios - 查询和 Firebase 中的位置(swift 3)