Discourse generated a certificate only for the www address. If you agree the apex domain via http you get redirected as you expect, but if you access it with https, you get an error.
There are some topics about how to generate a cert for both domains. You might see forcewww.com. That’s easier.