Create a Custom Domain for your Heroku App
So you've deployed your app on Heroku, but a URL of crowned.prawn.herokuapp.com doesn't exactly scream professional. If you want to make a custom domain name using Google Domain, here are the steps:
Pre-reqs:
- Deployed Heroku App
- Google Domain
Step 1: Buy a Domain Name
I'm using Google Domain but you can also use something like NameCheap.com.
- Go to https://domains.google/#/ and login to your account.
- Search for your desired domain name, add to cart, and then buy it at check-out. The domain price depends on the name that you get. $12.00/year is good benchmark price.
3. Congratulations! We just bought "foo-bar-bizz-fuzz-bit.com." Now click on the upper-left hamburger and go to DNS.
Step 2: Link your app to your domain
1. Scroll down to Synthetic records inside of DNS. This is where you'll redirect any subdomain to the domain that you just bought. Fill in an "@" sign for the Subdomain textbox and "www.yourDomainName.com" for your Destination URL.
The example above will be "@" and "www.foo-bar-bizz-fuzz-bit.com"
5. Scroll down to Custom resource records. This is where the linking happens. You want to get the DNS Target URL from Heroku. There's a couple of ways to do that:
- On the terminal: You can change directory (cd) to the root file of your app and enter the command "heroku domains". This should give you something like this:
- On Heroku: You can go to your Heroku App Settings. Scroll down to "Domains and Certificates" and you can add a domain there. Copy and paste the DNS Target.
6. Fill in the required items on Custom resource records at the Google Domain website.
Step 3: That's it! All that's left is to check your new domain.
Depending on your configuration, your app may go online ASAP or take as long as 72 hours. As soon as I stopped misspelling and type the correct fields in, I was able to see the live version of my custom domain website.
I hope this article helped someone! I wrote it to remind my future self of the entire process. Let me know if you have questions.