Firebase:为什么 $firebaseSimpleLogin 会引发 SecurityError? [英] Firebase: Why $firebaseSimpleLogin throws a SecurityError?

查看:39
本文介绍了Firebase:为什么 $firebaseSimpleLogin 会引发 SecurityError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Firebase 简单登录机制注册用户:

I'm trying to register users using the Firebase Simple Login mechanism:

angular.module('MyApp').controller('LoginCtrl', function($scope, $firebaseSimpleLogin, FIREBASE_ROOT) {
  $scope.loginService = $firebaseSimpleLogin(new Firebase(FIREBASE_ROOT));
  $scope.user = {
    email: '',
    password: ''
  };

  $scope.register = function() {
    console.log('creating user...'); // I see this
    $scope.loginService.$createUser($scope.email, $scope.password).then(function(user) {
      console.log('done!'); // But not this
      console.log(user);
    });
  };
});

但是,我在控制台中看到以下错误:

But, I see the following error in the console:

Uncaught SecurityError: Blocked a frame with origin 
"https://s-dal5-nss-15.firebaseio.com" from accessing a frame with origin
"http://localhost:8100".  The frame requesting access has a protocol of "https", 
the frame being accessed has a protocol of "http". Protocols must match.

并且,不会执行 $createUser 回调.

and, the $createUser callback is not executed.

我启用了电子邮件和密码"身份验证并将 localhost 放在授权请求来源列表中.

I enabled the "Email & Password" authentication and put localhost in the list of the Authorized Request Origins.

我做错了什么?

推荐答案

简单地说,您的域"(在本例中为 localhost)是 http 而源是 https,这往往会导致这些类型的错误.我相信如果它们匹配(但是,在这种情况下,两者都必须是 HTTPS),这应该不再是问题:

Simply put, your "domain" (localhost in this case) is http whereas the origin is https, which tends to cause these sorts of errors. I believe if they match up (however, in this case, both MUST be HTTPS), this should no longer be an issue:

请求访问的frame有一个https"的协议,frame被访问的协议为http".协议必须匹配.

The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.

可以在 REST API 参考 | 中找到更多信息Firebase 文档:

请注意,HTTPS 是必需的.Firebase 仅响应加密流量,以确保您的数据安全.

Note that HTTPS is required. Firebase only responds to encrypted traffic so that your data remains safe.

这篇关于Firebase:为什么 $firebaseSimpleLogin 会引发 SecurityError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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