Redirect domain to www for cloudflare pages

Hi everyone!
I created Cloudflare page and add my custom domain to it and it is working fine. But Now I want when user type my domain , he should redirect to from non www to www domain
For example example com should redirect my user to www example com.
I tried to add A, AAA, CNAME records and page rule, but it is showing an error.
kindly help me to solve this issue

You can follow our tutorial here: Redirecting www to domain apex · Cloudflare Pages docs
Just do it from apex → www rather than the other way around

It is showing 522 error.
I exactly did the same as was in article