cloudflare · Cloudflare Workers Docs
Workers Conditional response
Implements logic to return different HTTP responses based on request attributes such as URL, HTTP method, User Agent, IP address, ASN, or device type within a Cloudflare Worker.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Workers Conditional response
Implements logic to return different HTTP responses based on request attributes such as URL, HTTP method, User Agent, IP address, ASN, or device type within a Cloudflare Worker.
When To Use
Use when you need to route requests or modify responses based on specific client metadata like device type, IP address, or HTTP methods.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-examples-conditional-response-workflow-guide.md | A JavaScript example demonstrating how to return different HTTP responses based on request properties like URL, method, User Agent, and IP address in a Cloudflare Worker. | Questions about a JavaScript example demonstrating how to return different HTTP responses based on request properties like URL, metho... |
examples/workers-examples-conditional-response-cloudflare-workers-conditional-res.text | A JavaScript example demonstrating how to return different HTTP responses based on request hostname and URL path patterns in a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating how to return different HTTP responses based on request hostname and URL path patt... |
examples/workers-examples-conditional-response-cloudflare-workers-conditional-res-2.text | A JavaScript example demonstrating how to return different HTTP responses based on request hostname and URL patterns in a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating how to return different HTTP responses based on request hostname and URL patterns... |
examples/workers-examples-conditional-response-cloudflare-workers-python-conditio.text | A Python implementation for a Cloudflare Worker that returns different HTTP responses based on the request hostname or URL path. | Exact payloads, commands, or snippets shown in A Python implementation for a Cloudflare Worker that returns different HTTP responses based on the request hostname o... |
examples/workers-examples-conditional-response-cloudflare-workers-hono-conditiona.text | A Hono middleware implementation for Cloudflare Workers that returns conditional responses based on a list of blocked hostnames. | Exact payloads, commands, or snippets shown in A Hono middleware implementation for Cloudflare Workers that returns conditional responses based on a list of blocked... |
What This Skill Covers
- Return a response based on the incoming request's URL, HTTP method, User Agent, IP address, ASN or device type.
- 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/conditional-response
