How do you guys set up naked domains in Heroku apps?

Let's say:

I have and I want to allow anybody to type in the browser
# or
# or
# or

And to resolve/redirect to the secure version of it -> (non www)

It is basically done, following this approach:

  1. You need to go to the settings section in and enabling the SSL option(only available in hobby and paid plans)
  2. Add your domain with two variations inside the settings section within

  3. Create those two CNAMEs entries in your DNS providers (I'm using for free)

  4. Create a redirect rule in your application(this depend on the technology and language you are using), in my case, as I'm using Rails, so it was a matter of adding this to the top of the config/routes.rb file:

  match '(*any)',
    to: redirect(subdomain: ''),
    via: :all,
    constraints: { subdomain: 'www' }

There you go! you are ready to go, here is a live example (Site in construction as of November 26th, 2021)

All of them will resolve to the same domain: