Skip to content

feat(gateway): add path_prefix for reverse-proxy deployments#4145

Merged
theonlyhennygod merged 2 commits intomasterfrom
feat/gateway-path-prefix
Mar 21, 2026
Merged

feat(gateway): add path_prefix for reverse-proxy deployments#4145
theonlyhennygod merged 2 commits intomasterfrom
feat/gateway-path-prefix

Conversation

@theonlyhennygod
Copy link
Copy Markdown
Collaborator

Summary

  • Add optional gateway.path_prefix config field for deploying ZeroClaw behind a reverse proxy at a sub-path (e.g. /zeroclaw)
  • All gateway routes are nested under the prefix via Router::nest(), with a trailing-slash redirect
  • SPA fallback injects window.__ZEROCLAW_BASE__ into index.html so the frontend discovers the prefix at runtime
  • Frontend files (api.ts, sse.ts, ws.ts, main.tsx, App.tsx, Sidebar.tsx) prepend basePath to all URLs
  • Strict validation: must start with /, must not end with /, only URI-safe characters allowed

Review cleanup (vs original PR)

  • Removed redundant .map(str::trim) in gateway/mod.rs — validation already rejects whitespace
  • Ensured all existing tests have the new path_prefix field initialized

Adopted from #3709 by @slayer.
Supersedes #3709

Test plan

  • Verify cargo check passes (confirmed locally, linker issue is Xcode-license-related, not code)
  • Run cargo test for config schema validation tests (path_prefix accepts/rejects)
  • Test gateway startup with path_prefix = "/zeroclaw" behind nginx/caddy reverse proxy
  • Verify SPA loads correctly at the prefixed path
  • Verify WebSocket and SSE connections work under the prefix

Risk

Medium — touches src/gateway/** (high-risk area) but changes are additive and opt-in behind a new config field. No existing behavior changes when path_prefix is unset.

@theonlyhennygod theonlyhennygod force-pushed the feat/gateway-path-prefix branch from 8cd106c to 6527871 Compare March 21, 2026 12:14
@theonlyhennygod theonlyhennygod merged commit be40c0c into master Mar 21, 2026
25 of 27 checks passed
@theonlyhennygod theonlyhennygod deleted the feat/gateway-path-prefix branch March 21, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant