2

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

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

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

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不执行回调。

我启用了“电子邮件和密码”身份验证并将localhost其放入授权请求来源列表中。

我究竟做错了什么?

4

1 回答 1

1

简而言之,您的“域”(在这种情况下为 localhost)是http,而源是https,这往往会导致这类错误。我相信如果它们匹配(但是,在这种情况下,两者都必须是 HTTPS),这应该不再是一个问题:

请求访问的帧具有“https”协议,被访问的帧具有“http”协议。协议必须匹配。

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

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

于 2014-06-26T13:33:15.013 回答