How to fix “This operation is not supported in the environment this application is running on. ”location.protocol“ …” error?

人走茶凉 提交于 2020-05-31 23:31:11

问题


I try to use Firebase (Google) authentication but I'm getting this error:

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.

My code is:

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)
  });
}

The full error is:

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

回答1:


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 ...



来源:https://stackoverflow.com/questions/57506930/how-to-fix-this-operation-is-not-supported-in-the-environment-this-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!