cloudflare · Cloudflare Workers Docs
Workers Country code redirect
Implements a Cloudflare Worker to detect a visitor's country via request headers and perform a redirect based on that geolocation data.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Workers Country code redirect
Implements a Cloudflare Worker to detect a visitor's country via request headers and perform a redirect based on that geolocation data.
When To Use
Use when you need to implement automated URL redirection based on the geographic location of a user's request.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-examples-country-redirect-workflow-guide.md | A Cloudflare Workers example demonstrating how to redirect visitors based on the country code provided in the request headers. | Questions about a Cloudflare Workers example demonstrating how to redirect visitors based on the country code provided in the request... |
examples/workers-examples-country-redirect-cloudflare-workers-country-redirect-ja.text | A Cloudflare Worker script that uses the request country property to redirect users to localized URLs based on a mapping object. | Exact payloads, commands, or snippets shown in A Cloudflare Worker script that uses the request country property to redirect users to localized URLs based on a mapp... |
examples/workers-examples-country-redirect-cloudflare-workers-country-redirect-ja-2.text | A Cloudflare Worker script that uses the request country property to redirect users to localized URLs based on a mapping object. | Exact payloads, commands, or snippets shown in A Cloudflare Worker script that uses the request country property to redirect users to localized URLs based on a mapp... |
examples/workers-examples-country-redirect-cloudflare-workers-country-redirect-py.text | A Python Cloudflare Worker script that uses the cf object to redirect incoming requests to region-specific URLs based on the visitor's country code. | Exact payloads, commands, or snippets shown in A Python Cloudflare Worker script that uses the cf object to redirect incoming requests to region-specific URLs based... |
examples/workers-examples-country-redirect-cloudflare-workers-hono-country-redire.text | A Hono-based Cloudflare Worker script that maps visitor country codes to specific localized URLs. | Exact payloads, commands, or snippets shown in A Hono-based Cloudflare Worker script that maps visitor country codes to specific localized URLs. |
What This Skill Covers
- Redirect a response based on the country code in the header of a visitor.
- Main sections:
Tags.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.cloudflare.com/workers/examples/country-code-redirect
