I’ve made a Cloudflare Worker that returns requests based on the geographical location of the visitors. For instance, US workers go to the default server (
example.com) and European visitors get pages served from the
eu.example.com origin. But with the returned URL still
example.com. This way I cut down on geographical latency.
It works fine with workers, which is pretty cool .
Now I’m looking to shield all those origin servers (with duplicate content) from regular visitors. Is there a way to do that?
From what I understand I cannot simply issue redirects on
eu.example.com requests to
example.com, because that would also redirect workers themselves who fetch assets from
eu.example.com. Do workers have some kind of special signature (like a user-agent) that I can use to filter on before triggering a redirect? Or is there a better way to achieve my goal?