@PoojaPatel
Assuming, www is your canonical version for Discourse. But you installed Let’s Encrypt only for apex domain.
Here’s fix…
- Re-install Discourse
- Install SSL for your www because that is your canonical
- Restore Discourse backup
- Setup Cloudflare
- Go to DNS
- Enable its DNS only for www CNAME or A record.
- However must enable its DNS as well proxy for apex domain
- Choose Flexible SSL
- Force HTTPS
EXPECTED: HTTPS version should work fine for redirecting users from non-www to www version. Once I fixed SSL error this problem using this method.
Short version without re-installing SSL at www as per your canonical URL, That I cannot recommend.
(Setup Cloudflare proxy completely over www and non-www)