DNS A-records require that an IP address be hard-coded into your application’s DNS configuration
...which Heroku recommends avoiding. Heroku
You need a certificate that secures both www.example.com and example.com.