问题
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