设计确认链接将用户重定向到heroku域而不是自定义域 [英] Devise confirm link redirects user to heroku domain not a custom domain
问题描述
我有一个Web应用程序:Angular的前端和Rails的后端。
我有一个自定义域 www.example.com
并将用户重定向到heroku URL( example.herokuapp.com
)。
I have a web app: front-end in Angular and back-end in Rails.
I have a custom domain www.example.com
and redirects users to heroku URL(example.herokuapp.com
).
用户注册后,他们需要确认电子邮件。当他们从我的Web应用程序收到电子邮件时,他们单击链接。我使用Devise顺便确认用户的电子邮件。
应该将用户带到 www.example.com/log_in
。但是,由于某种原因,该用户被带到 example.herokuapp.com/log_in
。在这种情况下,如何将用户重定向到自定义域?
After user signs up, they need to confirm their emails. When they receive an email from my web app, they click the link. I use Devise to confirm user's email by the way.
It is supposed to take the user to www.example.com/log_in
. However, for some reason, the user is taken to example.herokuapp.com/log_in
. How do I redirect the user to custom domain for this edge case?
推荐答案
为此,您要覆盖 default_url_options
在您的环境配置文件中。例如,在您的 config / environments / production.rb
中,您可能需要以下内容:
To do this you want to override the default_url_options
in your environment config files. For example, in your config/environments/production.rb
you'll probably want the following:
config.action_mailer.default_url_options = {
host: 'http://www.example.com'
}
config.action_mailer.asset_host = 'http://www.example.com'
无论您设置主机$
default_url_options
中的c $ c>将成为通过ActionMailer发送的电子邮件(包括设计确认/密码重置电子邮件)中包含的所有链接的主机。 asset_host
用作您放置在电子邮件中的任何资产(例如图像)的主机,以便可以正确找到它们。
Whatever you set the host
of default_url_options
to will be the host of any links contained inside emails sent out through ActionMailer (this includes Devise confirmation / password-reset emails). asset_host
is used as the host for any assets (eg images) you put inside of your emails, so that they can be found correctly.
这篇关于设计确认链接将用户重定向到heroku域而不是自定义域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!