Files
llm-multiverse-ui/implementation-plans/issue-003.md
shahondin1624 298a186c31 feat: add Caddyfile for gRPC-Web reverse proxy with CORS support
- Route gRPC-Web requests to Orchestrator via h2c transport
- Handle CORS preflight and response headers for cross-origin access
- Proxy remaining traffic to SvelteKit dev server
- Configurable via env vars: ORCHESTRATOR_HOST, UI_HOST, DOMAIN, CORS_ORIGIN

Closes #3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 11:19:06 +01:00

1.5 KiB

Issue #3: Configure Caddy for gRPC-Web support

Status: COMPLETED Issue: #3 Branch: feature/issue-3-caddy-grpc-web

Summary

Create a Caddyfile that handles gRPC-Web translation, CORS headers, and proxies both gRPC-Web traffic to the Orchestrator and regular traffic to the SvelteKit dev server.

Acceptance Criteria

  • Caddyfile with gRPC-Web reverse proxy configuration
  • CORS headers configured for local dev and production origins
  • Content-Type mapping for gRPC-Web ↔ gRPC translation
  • grpc_web directive enabled (via content-type matching + h2c transport)
  • Documented how to run Caddy alongside the orchestrator
  • Browser can successfully call the Orchestrator through Caddy

Implementation

Single Caddyfile in the project root that:

  1. Routes application/grpc-web* requests to the Orchestrator via h2c
  2. Handles CORS preflight (OPTIONS) with configurable origin
  3. Adds CORS response headers for gRPC-Web responses
  4. Routes all other traffic to the SvelteKit dev server
  5. Configurable via environment variables: ORCHESTRATOR_HOST, UI_HOST, DOMAIN, TLS_MODE, CORS_ORIGIN

Deviations

  • Caddy v2 doesn't have a built-in grpc_web directive. Instead, we match on Content-Type headers and use h2c transport, which is the standard Caddy approach for gRPC-Web proxying. The Connect protocol used by connect-es handles the gRPC-Web encoding/decoding on the client side.