Heroku, GoDaddy, HTTPS, and Root Domains: How To Set It Up

Enable SSL, subdomains, forwarding, and make the correct DNS setup

Photo by Danial Igdery on Unsplash
  1. Have https://yourdomain.com as your root domain.
  2. Redirect http://yourdomain.com, http://www.yourdomain.com, and https://www.yourdomain.com to your root domain.
That moment when you see “Connection is secure”

Why GoDaddy And Heroku Aren’t Compatible

Root domains on Heroku require the use of ALIAS,ANAME, or FLATTENING records.

1. Add custom domains to Heroku

You need to add both domains here: yourdomain.com and www.yourdomain.com. You need to enable the ACM as well.

heroku domains:add yourdomain.com
heroku domains:add www.yourdomain.com
heroku certs:auto:enable
Pretty nice GUI!

2. Create a Cloudflare account (it’s free)

You will actually get much more benefits from CDN, but that’s not the point of this article.

CNAME    yourdomain.com    *.herokuapp.comCNAME    www               yourdomain.com
  1. Click “Create a new rule”.
  2. Let the setting be “Forwarding URL”, with the status code 301. You want to redirect from www.yourdomain.com/* to https://yourdomain.com. Enter those values into the input field.
  3. Don’t ignore this /*, otherwise, your redirects won’t work well for any path inside the app — just the root.

3. Set up nameservers in GoDaddy

Open your domain in GoDaddy, then click “Manage DNS”.

Go Daddy!

4. Party 🎉

There’s no step #4, that’s it! You can test your domain with curl -I yourdomain.com, and curl -I www.yourdomain.com.

London-based Frontend engineer and writer. I write about tech, success, and life | https://domagojvidovic.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store