Scoobyben
CDCloudflare Developers
•Created by Scoobyben on 10/23/2024 in #workers-help
Keen to understand the routing of a request invoked by a worker
I am fairly new to CloudFlare and interested in understanding the flow of my requests when workers are involved.
My current understanding is as follows:
* I have a proxied DNS record (CNAME) for a route in my domain
* As it's proxied, a bunch of CloudFlare rules etc. will be run on my request before being sent to the origin (AWS)
* At the end of this chain, my worker will be invoked - just one worker, based on the most specific matching path (?)
* If my worker then calls
fetch(request)
without doing anything else - what happens? The origin that the worker sees is my public-facing CloudFlare URL, not my actual origin (AWS). So to avoid infinite loops for even the most basic of workers, I expect something clever is going on. I'm not sure if the clever thing is
(a) fetch
within the worker runtime knowing to change the host to the origin configured in CF DNS (seems unlikely)
(b) Some metadata allowing CF to disable workers for this request, but re-running all other rules
(c) Some metadata allowing CF to disable workers and all other rules for this request
(d) Something else.
My current understanding is that (b) is happening - specifically because I have a transform rule changing the path of one of my requests, and when I try to fetch the request as provided in my worker - the path appears to be being modified again.
Thank you!13 replies