当前环境不支持指定的持久化类型firebase

ihn*_*dar 4 node.js firebase firebase-authentication

我收到这个错误。“当前环境不支持指定的持久化类型。” 我正在测试我的应用程序,发现当用户登录时,它会在任何地方登录。所以我正在尝试使用 firebase 在 node.js express 上实现会话,希望这能解决它。我的代码是这样的:

router.post("/login", function (req, res) {
email = req.body.email;
password = req.body.password;

firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION);
firebase.auth().signInWithEmailAndPassword(email, password).then(function () {
    var user = firebase.auth().currentUser;
    firebase.auth().onAuthStateChanged(function (user) {
        if (user) {

            res.redirect("/home");
        }
    });
});});
Run Code Online (Sandbox Code Playgroud)

boj*_*eil 9

nonenode.js 环境中仅支持持久性(这是默认设置)。这样做的原因是因为在服务器环境中使用 Firebase Auth 客户端库时,您可能有多个用户登录,并且您没有保留在后端服务器上的 currentUser 的概念(这会导致一个用户破坏其他)。会话持久性只能在客户端修改。