Pretty Easy
Can use a custom domain name on free Heroku but if you pay for a dyno you get “no-sleeping” and free SSL for custom domains (including automated cert mgmt.) with a hobby account that costs $7 a month for each app. You also get some application metrics (past 24 hours with 10 minute resolution) and you have 10 process types instead of 2 (not even sure what this means).
A domain on namecheap is like $9 a year and has free domain privacy.
In heroku go to your app and go the settings. Add a custom domain www.yoursite.com AND yoursite.com (without the www.) and this will generate DNS targets that you can copy paste into namecheap under the domain>Advanced DNS area.
For CNAME with host of www paste in the corresponding DNS target
For ALIAS with host of @ paste in the corresponding DNS target
Back in heroku you hit “Refresh ACM Status button” and you hopefully see green check marks and status of ok.
It may take some time but you should now have an SSL custom domain name for your heroku app.
// manually enforce https (snippet from jake trent site)
// breaks localhost so I comment this out while working locally
// and often forget to bring back in before re-deploying
/* if (process.env.NODE_ENV === "production") {
app.use((req, res, next) => {
if (req.header("x-forwarded-proto") !== "https") res.redirect(`https://${req.header("host")}${req.url}`)
else next()
})
} */
When you pull down and cancel your dyno you will get an error. I pulled the “force https” code, redeployed and still got the error. After seeing the logs and checking the error codes I found: “This is most likely the result of scaling your web dynos down to 0 dynos. To fix it, scale your web dynos to 1 or more dynos”
heroku ps:scale web=1
And you’re back up.
Remove “cname” and “alias” after adding with new host.