"Transform" the response body

Is it possible to transform the response body via a rule? I suspect this would need to be via a CF worker that acts as a proxy but hoping for a cleaner solution We are using origin/and response header rules to change the website from example.com to sample.com, but the website has hardcoded links inside the body (eg. hyperlinks) and we need to rewrite those as well
2 Replies
Chaika
Chaika•5mo ago
You'd need a worker and the html rewriter (https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/). But of course optimally you would just change those on the origin server. Workers are super fast and run everywhere with no cold starts, but still more expensive then not rewriting it for every request
semaja2
semaja2•5mo ago
Thanks, yeh unfortunately this is to deal with an expired domain that will take a few days to resolve its renewal, and the origin is managed by a 3rd party 😦 I suspect the worker would also take a bit of work to get working so might try to find another way forward as suggested