Firebase:为什么 $firebaseSimpleLogin 会引发 SecurityError?

编程入门 行业动态 更新时间:2024-10-25 17:27:22
本文介绍了Firebase:为什么 $firebaseSimpleLogin 会引发 SecurityError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试使用 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" 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 11:06:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023066.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Firebase   firebaseSimpleLogin   SecurityError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!