mirror of
https://github.com/benkoppe/traforo
synced 2026-03-09 23:57:14 -07:00
No description
- TypeScript 95.2%
- HTML 3.1%
- JavaScript 1.7%
Three bugs fixed in the tunnel proxy: 1. _tunnelId query param leaked into every HTTP request forwarded to the local server (e.g. /counter.ts?_tunnelId=xxx). Now stripped before building the proxy path. 2. WebSocket proxy dropped query params from the path — Vite HMR needs ?token=xxx to authenticate, which was silently lost. Now forwarded (minus _tunnelId). 3. DO did not echo Sec-WebSocket-Protocol in the 101 response, and the client did not forward the subprotocol when opening the local WS. Strict clients (ws library, Vite) rejected the connection. Now the DO echoes the protocol and the client forwards it to the local server. Added Vite HMR integration test that starts a Vite dev server, tunnels it through the preview deployment, and verifies: - HTML page loads through tunnel - Module requests work through tunnel - HMR WebSocket connects with vite-hmr protocol and receives full-reload messages when a .ts file is modified - Updated module content is served after file change Also fixed a pre-existing test that checked for lowercase 'offline' in the offline HTML page which uses 'Tunnel Offline' (capital O). |
||
|---|---|---|
| example-static | ||
| public | ||
| src | ||
| .gitignore | ||
| CHANGELOG.md | ||
| package.json | ||
| README | ||
| tsconfig.client.json | ||
| tsconfig.json | ||
| tsconfig.test.json | ||
| vitest.config.ts | ||
| wrangler.json | ||
TRAFORO
=======
HTTP tunnel via Cloudflare Durable Objects and WebSockets.
Expose local servers to the internet with a simple CLI.
INSTALLATION
------------
npm install -g traforo
USAGE
-----
Expose a local server:
traforo -p 3000
With a custom tunnel ID:
traforo -p 3000 -t my-app
Run a command and tunnel it:
traforo -p 3000 -- next start
traforo -p 3000 -- pnpm dev
traforo -p 5173 -- vite
The tunnel URL will be:
https://{tunnel-id}-tunnel.traforo.dev
OPTIONS
-------
-p, --port <port> Local port to expose (required)
-t, --tunnel-id [id] Tunnel ID (random if omitted)
-h, --host [host] Local host (default: localhost)
-s, --server [url] Custom tunnel server URL
--help Show help
--version Show version
HOW IT WORKS
------------
1. Local client connects to Cloudflare Durable Object via WebSocket
2. HTTP requests to tunnel URL are forwarded to the DO
3. DO sends requests over WebSocket to local client
4. Local client makes request to localhost and returns response
5. WebSocket connections from users are also proxied through
API ENDPOINTS
-------------
/traforo-status Check if tunnel is online
/traforo-upstream WebSocket endpoint for local client
/* All other paths proxied to local server
LIBRARY USAGE
-------------
import { TunnelClient } from 'traforo/client'
import { runTunnel } from 'traforo/run-tunnel'
const client = new TunnelClient({
localPort: 3000,
tunnelId: 'my-app',
})
await client.connect()
LICENSE
-------
MIT