Is a worker allowed to make requests to another worker?

I’m trying to setup a “catch-all” worker which acts in a similar way to a reverse proxy by looking at the URL path that’s been requested and then requesting content from a predefined application running on another worker within the same subdomain. Reason is so the “catch-all” worker can apply consistent http headers, navigation and footer elements while requesting dynamic content from the appropriate web app on the other workers.

There isn’t an “origin” as such because everything will be served from workers. Also each worker looks for a special http header applied by the router. Any requests without the special header are dropped. This prevents a visitor from browsing directly to the webapps.

Is this setup possible with Cloudflare? I seem to have read that one worker cannot call another within the same subdomain which seems very limiting and would make this architecture impossible without lots of different domains.


You can’t call another Worker in the same zone, be it (not sure if it’s per subdomain or the whole thing) or your own, but…

You can call other domains’ Workers. So this structure can be done with a worker on a domain you own (or on the subdomain) and then call the other via their URL (or on another domain you own). The important thing is that each layer is on a different domain from the previous, but you can simply alternate between two, and

1 Like