Firebase: Why $firebaseSimpleLogin throws a SecurityError?

喜你入骨 提交于 2019-12-12 18:51:01

问题


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.

and, the $createUser callback is not executed.

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

What am I doing wrong?


回答1:


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:

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

Some more info can be found on the REST API Reference | Firebase Documentation:

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



来源:https://stackoverflow.com/questions/24431924/firebase-why-firebasesimplelogin-throws-a-securityerror

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