x402 Icon

Payment-Gated
Reverse Proxy

A Cloudflare Worker that sits in front of any backend and gates access to protected routes with USDC payments. Zero backend modifications required.

/__x402/health • /__x402/protected

Template Features

01

Transparent Proxying

All non-protected requests pass through unchanged to your origin server. Your backend stays untouched.

02

Pattern-Based Protection

Configure routes with exact paths like /premium or wildcards like /api/private/*.

03

JWT Session Caching

After payment, a secure HttpOnly cookie grants 1-hour access without additional payments.

04

Configurable Pricing

Set custom USDC prices per route. Works on Base Sepolia (testnet) or Base mainnet.

05

Edge-Native

Runs entirely on Cloudflare Workers. Stateless design with no server-side session storage.

Client x402 Proxy (This Template) Origin Server Facilitator GET /api/* 402 or 200 Forward Response verify JWT Cookie

Built-in Test Endpoints

GET Health Check

/__x402/health

Public endpoint to verify the proxy is running. Returns JSON with status and timestamp.

Always accessible

GET Protected Test

/__x402/protected

Test payment flow without an origin server. Requires valid payment or session cookie to access.

Requires payment