Proxy the Request in Workers triggers Transform Rules more than once

Hey, I have a Worker code that gets the request, does some stuff, and then proxies it to the origin backend, after the response is available it does some more stuff and then responds to the client. So far so good I started to use the Dynamic URL Rewrite Transform Rule and I want every request to be prefixed with a “/v1”, for that I used concat(“/v1”, http.request.uri.path) I noticed that since the Worker is proxying the request, there’s the first Request from the Client to Cloudflare that triggers the Transform Rule and one more request from the Worker to the Origin Backend which also triggers the Transform Rule, I ended up with /v1/v1/<original_req_path> I tried to use the Custom Filter Expression and to skip if either Hostname, IP Source Address, Referer, or X-Forwarder-For are equal to 127.0.0.1 or localhost, also tried to Filter IP Source Address in case it is in the Cloudflare CIDRs Both approaches didn’t work Any idea how can I handle that? Thanks 🙂 (also posted to the community - https://community.cloudflare.com/t/proxyrequest-in-workers-triggers-transform-rules-more-than-once/557777)
1 Reply
Amnon
AmnonOP16mo ago
UP
Want results from more Discord servers?
Add your server