I wan't to restrict my worker don't locate at HongKong, how can I do this?

For Workes & Pages, what is the name of the domain?

don’t related to domain

What is the issue or error you’re encountering

I don’t want to my worker triggered at Hong Kong

Easiest way would be to use a Custom Domain or Worker Route, and then a Custom WAF Rule (Security → WAF → Custom Rules), and create a rule like hostname eq worker.custdomain.com and country eq Hong Kong (HK), like

If you don’t have a custom domain/want to do it entirely in the worker, off the Request object passed in you have req.cf.country which you can use in the same way, Hong Kong would be HK and then return a 403 response… You’d be paying for worker invocations on each blocked requests though

2 Likes

Thank you very much. This a easy for me. Actually, I don’t want to block user from HongKong, I just want when a request from HK, the the worker don’t use instance at HongKong but other country e.g. U.S., because the Anthropic API restrict invoke at Hong Kong. Can you give me some suggestion? :pray:

You can use Smart Placement to locate the Worker close to the back end instead of close to the user…

3 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.