Skip to content

Conversation

@mandelbro
Copy link
Contributor

Why

Resolves bug with confirmation email is incorrectly linking to port 38076

What

  • Set default mailer url for production

How

We determined that this problem exists both locally and on production, the prod server is likely using a non-standard port (38076) and that is being added to the confirmation url by the following line in config/application.rb:

    config.action_mailer.default_url_options = {
      host: ENV['SYSTEM_HOST_NAME'],
      port: (ENV['PORT'].presence || 80).to_i,
    }

Setting the host without the port should resolve this issue.

Testing

There are currently no tests for this as it is a devise method, but this should be tested in a demo environment to ensure it works as expected.

Next Steps

Test in the demo environment

Outstanding Questions, Concerns and Other Notes

None

Accessibility

N/A

Security

N/A

Meta

N/A

Pre-Merge Checklist

  • Security & accessibility have been considered
  • Tests have been added, or an explanation has been given why the features cannot be tested
  • Documentation and comments have been added to the codebase where required
  • Entry added to CHANGELOG.md if appropriate
  • Outstanding questions and concerns have been resolved
  • Any next steps have been turned into Issues or Discussions as appropriate

@mandelbro
Copy link
Contributor Author

For reference, there are several ways to set this default url, as outlined here: https://github.com/heartcombo/devise/wiki/How-To:-Set-:host-and-:port-for-all-devise-mailer-urls, but we decided setting in the production config was the lightest weight way to implement the fix.

@mandelbro
Copy link
Contributor Author

mandelbro commented Mar 12, 2021

Here's how we set it on our app

    default_url_options = {
      host: ENV.fetch('HOSTNAME'),
      locale: I18n.locale,
      protocol: ENV.fetch("URI_SCHEME")
    }

    config.action_mailer.default_url_options = default_url_options

Where the env variable is set to define HOSTNAME="localhost:3000" locally, and set to our production url on prod.

Copy link
Collaborator

@maebeale maebeale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES!

@solebared solebared merged commit bfd4d39 into rubyforgood:main Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants