相关疑难解决方法(0)

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

我尝试使用 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 …
Run Code Online (Sandbox Code Playgroud)

javascript firebase firebase-authentication

6
推荐指数
1
解决办法
7531
查看次数