2

我在我的 Rails 应用程序(使用 POW 在本地启动)中使用 Omniauth。在我的提供者返回回调操作后,我在端口 19999 中得到重定向。我不想将端口硬编码到 redirect_to 中(例如:)redirect_to root_url, :port => PORT

我想动态获取端口或了解为什么端口是 19999。

如果我正常启动我的应用程序 ( rails s -p 3000),端口不会更改为 19999。

4

1 回答 1

1

您可以使用以下方式设置回调 url 的主机OmniAuth.config.full_host

OmniAuth.config.full_host = "http://yourapp.dev"

这必须放在omniauth 被调用之前。我认为config/initializes/omniauth.rb是好的。

于 2014-09-15T16:14:43.983 回答