如何修复“在此应用程序运行的环境中不支持此操作.“位置.协议"……"错误? [英] How to fix "This operation is not supported in the environment this application is running on. "location.protocol" ..." error?
问题描述
我尝试使用 Firebase (Google) 身份验证,但出现此错误:
I try to use Firebase (Google) authentication but I'm getting this error:
运行此应用程序的环境不支持此操作.location.protocol"必须是 http、https 或 chrome-extension,并且必须启用网络存储.
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.
我的代码是:
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
推荐答案
不能用 NodeJS 运行客户端 JS,其中 location.protocol
可能是 typeof "undefined"代码>.您为环境使用了错误的客户端库;尝试另一个.JavaScript 和 JavaScript 不一定是同一个东西...
One cannot run client-side JS with NodeJS, where location.protocol
might likely be typeof "undefined"
. You're using the wrong one client library for the environment; try the other one. JavaScript and JavaScript are not necessarily the same thing ...
这篇关于如何修复“在此应用程序运行的环境中不支持此操作.“位置.协议"……"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!