如何修复“此应用程序运行的环境不支持此操作。“location.protocol”...”错误?

Bud*_*Örs 6 javascript firebase firebase-authentication

我尝试使用 Firebase (Google) 身份验证,但收到此错误:

\n\n
\n

此应用程序运行的环境不支持此操作。“location.protocol”必须是 http、https 或 chrome-extension,并且必须启用 Web 存储。

\n
\n\n

我的代码是:

\n\n
var provider = new firebase.auth.GoogleAuthProvider();  \n\nfunction Singin(){\n  firebase.auth().signInWithPopup(provider).then(function(result) {\n    var user = result.user;\n    console.log(user);\n  }).catch(function(error) {\n    console.log(error);\n    console.log(error.message)\n  });\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

完整的错误是:

\n\n
zi {code: "auth/operation-not-supported-in-this-environment", message: "This operation is not supported in the environment\xe2\x80\xa6chrome-extension and web storage must be enabled."}\ncode: "auth/operation-not-supported-in-this-environment"\nmessage: "This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled."\n__proto__: Error\n
Run Code Online (Sandbox Code Playgroud)\n

Mar*_*ler 0

无法使用 NodeJS 运行客户端 JS,location.protocoltypeof "undefined". 您在环境中使用了错误的客户端库;尝试另一种。JavaScript 和 JavaScript 不一定是同一件事......

  • 有人找到了这个问题的解决方案吗?通过 Xcode iPhone 13 模拟器运行离子电容器应用程序时出现相同的错误。 (2认同)