Yesterday I decided to start blogging and chose this cool blog (Ghost) and bought a domain that would point to my Heroku app.

I tried to do the deploy by myself but there was numerous problems when deploying the app to Heroku and also I didn't have enough time to spend for that. So I found a cool solution built by http://cobyism.com. It's just a button which on click do all the work of deploying the Ghost blog to the Heroku servers. You can found it here: http://cobyism.com/ghost-on-heroku/

Heroku Configuration

First, I had to configure the Heroku app. The configuration was simple and consists of only adding the domain name and get the DNS Target which is needed for the domain's DNS configuration. So, you can find this settings at:
Personal Apps -> YOUR_APP -> Settings -> Domains and certificates
There you have to just add your domain. I had to add both the seishin.me and www.seishin.me.
Domain Settings

Domain Configuration

As for the domain, I bought it from GoDaddy. The DNS configurations page was different from the one I used to use before. Anyway, this is the configuration:
Type: CNAME
Name: www
Value: YOUR_HEROKU_DNS_TARGET

Also you have to setup a forwarding:
FORWARD TO: YOUR_DOMAIN
FORWARD TYPE: Permanent (301)
And don't forget to check the Update my nameservers and DNS settings to support this change.

Now after you wait for a bit, you expect to open your web site when you hit the newly bought domain, right? But... hmm... Not exactly! 👻

When you open the domain, in my case: www.seishin.me, it redirects me to: seishin.me.herokudns.com which is not the expected behavior, right? 👨‍💻

So, after a lot of researching, I came across this StackOverflow answer from Michael Fulton 👏
The solution was so simple! You just have to update the HEROKU_URL environment variable to be your custom domain! In my case I have to change it from https://seishinblog.herokuapp.com to http://www.seishin.me

In conclusion

Configuring a domain is an easy job but you have to have some knowledge in that field... Or you will spent a few hours searching for a solution just like me! 😁

So I hope that this story will help you configuring your Heroku app to get to work with custom domain.