I have a similar issue and using a URL redirect record at the DNS level doesn’t solve the problem for me.
I installed Discourse using the hostname ‘www.example.com’ and the following DNS records:
A Record host:WWW value:my_server_ip
CNAME host:@ value: www.example.com
URL Redirect Record host:@ value:https://www.example.com
If I then use SSL Server Test (Powered by Qualys SSL Labs) to check the URL https://example.com without the WWW I get a Certificate name mismatch and in my browser a NET::ERR_CERT_COMMON_NAME_INVALID error.
Apologies again if I’m missing something obvious here, networking isn’t my strong point!