Understand this first: a Cloudflare Worker intercepts HTTP requests via a route pattern. Your origin receives a normal request. Zero backend changes. Every other demo on this site works exactly this way.
Core concept
0
backend changes
10s
to deploy
330
cities globally
Browser
user request
⚡ Cloudflare Edge
330 cities, 125+ countries
Route Match
*shoplegacy.com/*🤖 Worker
① Request phase
○ await fetch(origin)
② Response phase
○ HTMLRewriter.transform()
Your Origin
unchanged
Live comparison
Left: origin only, no Worker. Right: Worker route active — AI chatbot injected at the edge via HTMLRewriter. The origin code is identical in both.
STRANDMON Wing Chair
SKU: STR-4892
$299.00
High-back wing chair for great support. Perfect for reading and relaxing.
❌ No chatbot
Questions? Email support@shoplegacy.com
Reply time: 3–5 business days
STRANDMON Wing Chair
SKU: STR-4892
$299.00
High-back wing chair for great support. Perfect for reading and relaxing.
How to do this
✏️ Write a Worker
A TypeScript file. Check the path, fetch from origin, transform the response. Guard non-HTML paths so binary assets pass through.
🗺 Add a route
One line in wrangler.toml. Wildcards supported. Multiple routes per Worker.
🚀 Deploy
wrangler deploy. Live globally in 10 seconds. Rollback is one command too.
# wrangler.toml — the only file you add to your project name = "my-worker" main = "worker.ts" compatibility_date = "2026-04-23" # Workers AI binding — gives the Worker access to 50+ AI models [ai] binding = "AI" # Route — Worker runs IN FRONT of an existing origin (your backend). # Use this when your origin already exists (Pages, Workers, S3, EC2, your VPS). # Requires a proxied DNS record for the hostname (orange-cloud in Cloudflare DNS). [[routes]] pattern = "*shoplegacy.com/*" # wildcards supported zone_name = "shoplegacy.com" # your zone in Cloudflare # Alternative: Custom Domain — use when the Worker IS the origin # (no upstream server). Cloudflare auto-creates the DNS + SSL cert. # [[routes]] # pattern = "store.shoplegacy.com" # custom_domain = true # ─── Nothing else changes ──────────────────────────────────────── # Your origin server code: untouched # Your DNS A/CNAME records: untouched (proxied record required) # Your SSL certificate: untouched # Your database: untouched # Your existing deployments: untouched
Productionising this