Cloudflare Workers
Tollbooth cannot run on Cloudflare Workers in its current form. This page explains why and lists alternatives that still let you use Cloudflare’s network.
Incompatibilities
Section titled “Incompatibilities”| Tollbooth dependency | Workers support | Issue |
|---|---|---|
Bun.serve() | No | Workers use a fetch() handler export, not a long-lived HTTP server |
Bun.file() | No | Workers have no filesystem access |
| YAML config loading from disk | No | No filesystem — would need KV or R2 |
Dynamic import() for hooks/pricing | Limited | Workers require static imports |
| Long-lived HTTP server | No | Workers are request-scoped |
node: built-ins | Partial | Only a subset is available via the nodejs_compat flag |
What a port would require
Section titled “What a port would require”To run tollbooth natively on Workers, you’d need to:
- Replace
Bun.serve()with a Workersfetch()handler export - Externalize config into KV, R2, or environment variables
- Remove all dynamic
import()calls in favor of static imports - Replace Bun-specific APIs (
Bun.file(), etc.) with Workers equivalents - Test the full x402 payment flow under Workers request-scoping constraints
This is a non-trivial effort and not currently planned.
Alternatives
Section titled “Alternatives”Cloudflare Tunnel
Section titled “Cloudflare Tunnel”Run tollbooth on any server (VPS, local machine, etc.) and expose it through Cloudflare’s network using cloudflared. You get Cloudflare’s CDN, DDoS protection, and SSL — without needing Workers.
# Install cloudflared# https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/
# Authenticatecloudflared tunnel login
# Create a tunnelcloudflared tunnel create tollbooth
# Route your domain to the tunnelcloudflared tunnel route dns tollbooth tollbooth.example.com
# Run the tunnel, pointing to your local tollbooth instancecloudflared tunnel run --url http://localhost:3000 tollboothVPS + Cloudflare proxy
Section titled “VPS + Cloudflare proxy”Run tollbooth in Docker on any VPS, point your domain’s DNS to the VPS via Cloudflare, and enable the orange-cloud proxy. This gives you Cloudflare’s CDN and SSL with a standard Docker deployment.
Managed platforms
Section titled “Managed platforms”For the simplest managed deployment, see the Fly.io and Railway guides.