Overview
Thewebhook command starts a specialized HTTP server that captures and displays incoming webhook requests in real-time. It automatically creates a Cloudflare tunnel and opens a web dashboard for inspecting requests.
Syntax
Parameters
This command takes no parameters. It uses the default webhook port from your configuration.Usage Examples
Output
The command displays:- A spinner: “Starting tunnel, this may take a second…”
- The webhook URL in cyan color
- Automatically opens the webhook dashboard in your browser
Example Output
Dashboard Features
The web dashboard (athttps://cli.ahh.bet/webhook) provides:
- Real-time webhook request monitoring
- Request details including:
- HTTP method (GET, POST, PUT, DELETE, etc.)
- Request path
- Timestamp
- Headers (filtered for privacy)
- Query parameters
- Request body
- Unique request IDs for tracking
How It Works
Server Architecture
- HTTP Server: Accepts all HTTP methods on all paths
- WebSocket Connection: Streams request data to the dashboard
- Token Authentication: Secures the WebSocket connection with a UUID token
- Request Capture: Logs all incoming requests with full details
Request Flow
Authentication
The dashboard authenticates via:- A random UUID token generated on server start
- Token embedded in the dashboard URL
- WebSocket connection requires token verification
- Unauthorized connections are terminated
Request Data Captured
Each webhook request captures:Header Filtering
For privacy and clarity, the following headers are filtered out:
- Headers starting with
cf-(Cloudflare headers) - Headers starting with
x-forwarded(proxy headers) cdn-loopheader
Default Configuration
The webhook server uses theDEFAULT_WEBHOOK_HTTP_PORT from your Ahh configuration file. You can modify this in your config.
Technical Details
Implementation
Built with:- Elysia - HTTP server framework
- WebSocket - Real-time communication
- CORS - Restricted to
cli.ahh.betdomain
WebSocket Endpoint
The WebSocket endpoint is at/ws and:
- Requires token authentication via first message
- Broadcasts to all connected clients
- Automatically cleans up closed connections
- Returns “OK” on successful auth
All HTTP Methods Supported
The server accepts:- GET
- POST
- PUT
- DELETE
- PATCH
- HEAD
- OPTIONS
- Any other HTTP method
Return Value
The underlyingcreateWebhookServer() function returns:
Error Handling
Tunnel Creation Failure
If the tunnel fails to create:WebSocket Connection Errors
Unauthorized WebSocket connections are:- Immediately terminated
- Not added to the client list
- Not able to receive request data
Notes
The webhook server responds with “OK” to all requests, making it suitable for services that expect a 200 response.
All request data is only streamed to connected dashboard clients. No data is persisted to disk.
