为什么 ROOT_URL 是捆绑部署所需的环境变量? [英] Why is ROOT_URL a required environment variable for bundle deployment?

查看:47
本文介绍了为什么 ROOT_URL 是捆绑部署所需的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Meteor 应用程序为多个域提供服务.该应用的功能对于所有网站都是相同的,但主机名决定了我呈现的模板.

I have my Meteor app serving for a number of domains. The app's functionality is the same for all sites, but the host names dictate which templates I render.

当我在生产环境中运行 Meteor 应用程序且 ROOT_URL 仅指向一个域时,一切正常.所以我想知道,为什么这是一个必需的环境变量,而不是在 Meteor.absoluteUrl() 中使用它?(我个人不使用它,尽管我知道它可能会在引擎盖下的其他地方使用)

Everything works fine when I run my Meteor app in production with ROOT_URL pointing to only one of the domains. So I'm wondering, why is this a required environment variable other than for its use in Meteor.absoluteUrl()? (which I personally don't use though I recognize it may be used elsewhere under the hood)

推荐答案

在生产环境中使用这个是在 OAuth 回调期间.如果您通过 Facebook/Twitter/Google 或其他一些第三方登录,它会回调到您的域,并且您的浏览器必须正确路由.

The use of this in production environments is during OAuth callbacks. If you log in via Facebook/Twitter/Google or some other third party it will call back to your domain and your browser has to route this correctly.

在 OAuth 中,使用的域必须与为了安全而提供给另一方的域相匹配.另一个是为了让 OAuth 登录提供程序(如 facebook)知道重定向回何处.

In OAuth the domain used must match the one given to the other side for security. The other is so that the OAuth login provider, like facebook knows where to redirect back to.

所以这是通过 ROOT_URL 传递的.例如,对于 facebook,登录时会重定向回 Meteor.absoluteUrl('_oauth/facebook?close')

So this is passed on through the ROOT_URL. e.g for facebook when logging in would redirect back to Meteor.absoluteUrl('_oauth/facebook?close')

这篇关于为什么 ROOT_URL 是捆绑部署所需的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆