URL rewrite if header contains substring

Hi

My website currently uses Azure CDN, but I’m thinking about moving it to Cloudflare, since Azure CDN doesn’t support free HTTPS for the apex domain.

However because of a quirke in the client-side library I’m using, I currently have this URL rewrite in my CDN:

If the accept header starts with the string “text/html”, then rewrite the path to “/index.html”.

Notice that this is a rewrite and not a redirect, because the client side code must know the original path.

Is this possible to achieve with Cloudflare?

Big thanks for any help!