How do I redirect www to root domain?

Hi, I'm hosting a Next.js app on a Cloudflare Worker (first time doing this, I usually use Vercel).

My goal is to set up a permanent 301 redirect from www.domain.com to the apex/root domain (where the Worker runs).

I used the Cloudflare Redirect Rule template in the dashboard, but it's not working. Traffic to www.domain.com is failing/not redirecting.
Was this page helpful?