我尝试使用Firebase(Google)身份验证,但出现此错误:
在运行该应用程序的环境中不支持此操作。 “ location.protocol”必须为http,https或chrome-extension,并且必须启用网络存储。
我的代码是:
var provider = new firebase.auth.GoogleAuthProvider();
function Singin(){
firebase.auth().signInWithPopup(provider).then(function(result) {
var user = result.user;
console.log(user);
}).catch(function(error) {
console.log(error);
console.log(error.message)
});
}
完整错误是:
zi {code: "auth/operation-not-supported-in-this-environment", message: "This operation is not supported in the environment…chrome-extension and web storage must be enabled."}
code: "auth/operation-not-supported-in-this-environment"
message: "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."
__proto__: Error
答案 0 :(得分:1)
一个人无法使用NodeJS运行客户端JS,其中location.protocol
可能是typeof "undefined"
。您为环境使用了错误的一个客户端库;尝试the other one。 JavaScript和JavaScript不一定是同一回事...
答案 1 :(得分:-1)
我也遇到了这个错误。 我通过在线托管项目来修复它