A common scenario is that you want to redirect requests from an apex domain like example.com to www.example.com - this can often be performed at your DNS provider level if they offer that service.
However, if you want to redirect requests to https://example.com to https://www.example.com and you're using a redirect service provided by your DNS provider then you may see failures. This is often because your DNS provider does not have a valid certificate for your domain so when a browser makes a request to https://example.com then the request will fail. In this scenario you'd need to use a DNS provider that supports ANAME/ALIAS records so the record can be configured to resolve directly to your applications address which would be configured with a valid certificate. You can then handle the redirect at the application level.