GatewaysAugust 22, 2026·9 min read

API Gateway on Cloudflare Workers: JWT, Caching & Canary

Deploy a full API gateway as a Worker — path routing, JWT HS256 validation, header transforms, response caching, canary splitting and IP allow/deny in 60 seconds.

What an API gateway does

A gateway sits in front of your upstreams and decides: who can call, where they go, and what gets changed along the way. EdgeBalancer's gateway is a generated Worker with nine features — path-based routing, HMAC JWT validation (HS256/384/512), CORS, request/response header rewrites, GET response caching via Cache API, deterministic canary splitting by client IP, IP allow/deny lists, mock routes and rate limiting.

Path routing + canary

pathRoutes maps /api/v2/* → upstream 1, /static/* → upstream 0. Canary is a deterministic hash of cf-connecting-ip modulo 100 — same visitor always hits same variant, no external state. Changing the percentage triggers a Worker version deploy with rollback.

JWT + headers + caching

JWT secrets are AES-256-GCM encrypted at rest and verified with Web Crypto in the Worker (~2ms). Header transforms are baked into the script; caching uses Workers Cache API and honors per-path TTL.

When to use it

  • A single domain fronting 3 microservices
  • Protecting a paid API with JWT without a separate auth service
  • Gradual rollout (canary 10% → 50% → 100%)

#api gateway#cloudflare workers#jwt#caching

Ready to try it?

Deploy your first load balancer in 90 seconds. Free under 100k requests/day.

Start free →