I have an app deployed on Heroku and using Cloudflare as my DNS Server. I have generated an SSL Certificate on Cloudflare and successfully uploaded it on Heroku. I have obtained my DNS Target from Heroku and created the following two CNAMEs on Cloudflare:
CNAME mydomain.com "Proper DNS Target from Heroku" Proxied
CNAME www "Proper DNS Target from Heroku" Proxied
I have also created the following rule on Cloudflare:
https://mydomain.com/*
Forward URL to https://www.mydomain.com/$1
The URL https://www.mydomain.com resolves properly. However, it doesnât when I do not use the âwwwâ (i.e. https://mydomain.com ).
I have tried numerous different configurations suggested online, but none worked.
Thank you @KianNH Yes, I have carefully followed that guide and did obtain 2 different CNAME Targets from Heroku and used the proper ones for each corresponding CNAMEs on Cloudflare, but nothing seems to work (proof that I havenât mixed them is that the URL using the www works). I will look at it again. Thanks again.
I vaguely recall someone else having the same kind of issues in the past (setting up @ and www for a Heroku site) but I canât really remember what their solution ended up being.
When you say that the root domain doesnât work, what exactly does ânot workingâ entail?
Can you visit the site but get a Heroku ânot foundâ or are you getting a Cloudflare error page?
I am getting âThis site canât be reachedâ. If I use try curl -I mydomain.com, I get âCould not resolve hostâ. Thus, the problem seems to be on the Cloudflare side.
I donât actually know how itâs possible (since entering mydomain.com instead of @ will treat it as if you meant @ in the UI) but Iâve seen it before.
Yes, this was the problem!!! Although I wasnât seeing a duplicate domain name in the CNAME Field, it has answered on both dig commands. After editing the CNAME using only â@â, the non-www url started resolving. I must have initially entered the domain name when creating the CNAME. I thank you very, very much! Have a Great day.
Iâve never actually been able to recreate it myself - no matter how I do it, new record or changing an existing one, entering mydomain.com as the record name is put on mydomain.com rather than mydomain.com.mydomain.com like in your case.