Skip to main content
The Gateway Worker is the main entry point for all API requests. It handles routing, authentication, and request proxying.

Architecture

The worker is a simple request handler that processes incoming requests and routes them to appropriate handlers:

Environment Interface

Key Functions

handleLogin

Authenticates admin users and issues JWT tokens.

handleGuestToken

Generates temporary guest tokens for unauthenticated access.

handleProxy

Proxies requests to downstream services with authentication verification.

verifyToken

Verifies JWT tokens and validates route matching.

Helper Functions

Password Hashing

URL Rewriting

Error Responses

All errors follow the unified GatewayErrorSchema:

CORS Handling

The gateway handles CORS preflight requests:

Configuration

wrangler.toml

Deployment

Deploy the gateway worker:
Or use the deployment script: