我遇到了一个问题,我的应用程序正在生成从邮件程序到www.myurl.herokuapp.com/:8080/someurl的链接-这破坏了我所有的链接,因为它们可以工作,但是没有添加:8080。也就是说,如果我手动删除/:8080 /,它就可以正常工作。
例如,通过电子邮件发送的重置密码生成的URL为:
https://myurl.herokuapp.com/:8080/users/password/edit?reset_password_token=123token123
但是,它在开发中运行良好,只是生产存在问题。我已经设法通过对某些URL使用静态URL来对其进行破解,但是对于密码重置和长期健康,我需要对其进行修复。
我正在使用: Ruby 2.3.1 Rails 5.1.4 Heroku PGSQL SendInBlue作为邮件程序
我尝试过的事情:
在reset_password_instructions.html.erb中:
更改以下行:
<p><%= link_to 'Change my password', edit_password_path(@resource, reset_password_token: @token) %></p>
我还尝试过从production.rb中删除默认端口:
config.action_mailer.default_url_options = {主机:'http://myurl.herokuapp.com/'}
任何人都可以建议造成此问题的原因或解决方法吗?
错误消息:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
单击电子邮件中的链接时,日志似乎并没有抛出任何新内容,实际上它们没有生成任何内容(?),这是日志中的最后一件事:
2018-09-25T21:16:06.581471+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-25T21:16:06.709308+00:00 heroku[web.1]: Process exited with status 143
2018-09-25T21:27:39.622506+00:00 heroku[router]: at=info method=GET path="/szallodak/4909;;;" host=staging.herokuapp.com request_id=0eb96201-d562-46d2-93aa-759324d0c64d fwd="95.216.157.196" dyno=web.1 connect=0ms service=6ms status=301 bytes=170 protocol=http
2018-09-25T21:27:41.361516+00:00 heroku[router]: at=info method=GET path="/szallodak/4909" host=staging.herokuapp.com request_id=cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677 fwd="95.216.157.196" dyno=web.1 connect=0ms service=132ms status=404 bytes=1966 protocol=https
2018-09-25T21:27:41.227565+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] Started GET "/szallodak/4909" for 95.216.157.196 at 2018-09-25 21:27:41 +0000
2018-09-25T21:27:41.355281+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677]
2018-09-25T21:27:41.355383+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] ActionController::RoutingError (No route matches [GET] "/szallodak/4909"):
2018-09-25T21:27:41.355437+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677]
2018-09-25T21:27:41.355533+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
2018-09-25T21:27:41.355535+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:36:in `call_app'
2018-09-25T21:27:41.355530+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
2018-09-25T21:27:41.355537+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:24:in `block in call'
2018-09-25T21:27:41.355539+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:69:in `block in tagged'
2018-09-25T21:27:41.355540+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:26:in `tagged'
2018-09-25T21:27:41.355542+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:69:in `tagged'
2018-09-25T21:27:41.355544+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:24:in `call'
2018-09-25T21:27:41.355545+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
2018-09-25T21:27:41.355547+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/request_id.rb:25:in `call'
2018-09-25T21:27:41.355548+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
2018-09-25T21:27:41.355550+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
2018-09-25T21:27:41.355552+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
2018-09-25T21:27:41.355554+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
2018-09-25T21:27:41.355555+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/static.rb:125:in `call'
2018-09-25T21:27:41.355557+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
2018-09-25T21:27:41.355558+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/ssl.rb:68:in `call'
2018-09-25T21:27:41.355560+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:522:in `call'
2018-09-25T21:27:41.355561+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/puma-3.12.0/lib/puma/configuration.rb:225:in `call'
2018-09-25T21:27:41.355563+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/puma-3.12.0/lib/puma/server.rb:658:in `handle_request'
2018-09-25T21:27:41.355564+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/puma-3.12.0/lib/puma/server.rb:472:in `process_client'
2018-09-25T21:27:41.355566+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/puma-3.12.0/lib/puma/server.rb:332:in `block in run'
2018-09-25T21:27:41.355568+00:00 app[web.1]: [cdc1c6e4-ce66-404c-a4a7-ed8a7c7eb677] vendor/bundle/ruby/2.4.0/gems/puma-3.12.0/lib/puma/thread_pool.rb:133:in `block in spawn_thread'
2018-09-25T21:27:41.657427+00:00 heroku[router]: at=info method=GET path="/szallodak/4909;;;" host=staging.herokuapp.com request_id=47227af4-6a27-4265-8f9f-357d89889a92 fwd="95.216.157.196" dyno=web.1 connect=0ms service=3ms status=301 bytes=170 protocol=http
答案 0 :(得分:0)
非常容易修复具有相同问题的其他任何人,在production.rb中,我只是添加了“,protocol:'https'”,因此现在显示为:
config.action_mailer.default_url_options = { host: 'http://myapp.herokuapp.com',
protocol: 'https' }
如果您的协议不是https,则只需使用http://
我也恢复了路径(尽管我没有使用path测试),两者都应该起作用:
<p><%= link_to 'Change my password', edit_password_path(@resource, reset_password_token: @token) %></p>
到
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>