Rewriting HTML weird problems

I am trying to rewrite some links using the example from here: https://developers.cloudflare.com/workers/examples/rewrite-links/.

  1. The first problem is that the target website is using WP Rocket and that is removing the Content-Type header, so I need an alternative solution to that (check content type).

  2. The second problem is that even if I load the page in the browser (with caching disabled, Content-Type header present), nothing will get rewritten. I suspect this is because the await fetch(req); is fetching the cached content served by WP Rocket. I`m not sure what the solution is for this, I want to rewrite the HTML regardlress of any caching methods/plugins on the source. This should be possible since the worker should be the “last in chain”? Please advise.

Many thanks!