当网站使用 SSL 时,accounts-facebook 因 SecurityError 而失败

accounts-facebook fails with SecurityError when the site uses SSL

我的 meteor 应用目前已经存在 "unsecured" - 这意味着默认情况下不会重定向到 https://。这与 accounts-facebook 包结合使用效果很好,它在执行 OAuth 魔法时创建自己的启用 SSL 的 Facebook 连接。

当我尝试使用 https 而不是 http 访问我的网站时,我的问题就开始了。弹出 window 帐户包打开以登录 facebook 的弹出窗口很快停止,通过读取其控制台输出,我可以看到以下消息

Uncaught SecurityError: Blocked a frame with origin "http://wishlist-foobar.meteor.com" from accessing a frame with origin "https://wishlist-foobar.meteor.com". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.

我认为这可能与应用程序的 facebook 设置中的站点 url 有关,但在该设置中将 http 更改为 https 让我无处可去。仍然收到相同的消息。这应该如何工作?除了 facebook 设置之外,我没有对路径的 http 部分进行硬编码,所以这似乎是 accounts-facebook 包正在做的事情。

这是我在 Facebook 上的应用设置。观察非 SSL 站点 url。

事实证明,您需要设置 ROOT_URL 环境变量才能使回调正常工作,并确保访问者点击 url(例如,强制使用 ssl)。有关更多背景信息,请参阅这些 SO 答案。

  • Why is ROOT_URL a required environment variable for bundle deployment?