It depends where you registered your domain, but you can’t use a CNAME for the root domain. You’ll need to use an ALIAS or ANAME instead.
I use Google Domains, and they don’t offer ALIAS or ANAME. So, I had to do a CNAME for the www subdomain (as you mentioned above) pointing to Heroku. Then, I set up a 301 Redirect with “forward path” and “enable SSL” from the root domain (‘@’) to the www subdomain.
Your domain provider will likely have a different interface than Google Domains, so I can’t be more specific. But that’s a potential solution.