如何修复“此应用程序在其上运行的环境中不支持此操作". "location.protocol" ..."错误? [英] How to fix "This operation is not supported in the environment this application is running on. "location.protocol" ..." error?

查看:125
本文介绍了如何修复“此应用程序在其上运行的环境中不支持此操作". "location.protocol" ..."错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用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 ...

这篇关于如何修复“此应用程序在其上运行的环境中不支持此操作". "location.protocol" ..."错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆