How it works

xpose uses Cloudflare Workers and Durable Objects to create a serverless tunnel between your local machine and the internet.

Architecture

Browser → Cloudflare Worker → Durable Object ↔ CLI → localhost

Step by step

  1. CLI connects via WebSocket

    The xpose CLI establishes a WebSocket connection to a Cloudflare Worker at your subdomain.

  2. Worker creates a Durable Object

    The Worker creates (or resumes) a Durable Object that manages the tunnel session. Each subdomain maps to exactly one Durable Object.

  3. Traffic hits the public URL

    When someone visits your public URL, the request hits the Cloudflare Worker, which forwards it to the Durable Object.

  4. DO multiplexes through WebSocket

    The Durable Object encodes the HTTP request into a binary frame and sends it through the WebSocket to your CLI. Multiple requests can be in-flight at once.

  5. CLI forwards to localhost

    The CLI receives the request, forwards it to your local server, and sends the response back through the same WebSocket channel.