Skip to content

feat(relay): BUZZ_WEB_SPA=full to serve a full client bundle - #3027

Open
flaukowski wants to merge 1 commit into
block:mainfrom
flaukowski:upstream-web-spa
Open

feat(relay): BUZZ_WEB_SPA=full to serve a full client bundle#3027
flaukowski wants to merge 1 commit into
block:mainfrom
flaukowski:upstream-web-spa

Conversation

@flaukowski

Copy link
Copy Markdown

Problem

should_serve_spa only falls back to the SPA shell for the invite landing page, and optionally the bundled git browser:

fn should_serve_spa(path: &str, serve_git_web_gui: bool) -> bool {
    is_invite_landing_path(path) || (serve_git_web_gui && is_git_web_gui_path(path))
}

A deployment that points BUZZ_WEB_DIR at a full client bundle has no way to get client-side routing for its own paths — every route needs a bespoke predicate compiled into the router. Any client-side route reached by deep link or refresh 404s.

Change

Add BUZZ_WEB_SPA=full. When set, any path the relay does not serve itself falls back to index.html.

Server-owned paths still return their own responses, so a mistyped API call 404s instead of returning HTML that a client would then try to parse as JSON:

/api/…, /git/…, /hooks/…, /media/…, /upload, /.well-known/…, /_*, /events, /query, /count, /info, /health, /moderation

Defaults to false. With the variable unset, behaviour is unchanged.

Tests

Three new cases in crates/buzz-relay/src/router.rs:

  • full_spa_mode_serves_arbitrary_client_routes — opt-in serves paths the relay has never heard of
  • full_spa_mode_still_lets_server_paths_404 — every server-owned prefix must not fall back
  • full_spa_mode_is_off_by_default — unknown paths still 404 without the opt-in

Plus a default-value assertion in the config tests, and a TESTING.md row for the new variable.

Context

We run a self-hosted Buzz deployment whose web bundle is a full workspace client. We had been carrying a hardcoded path predicate in should_serve_spa to make it work; this generalises that into an opt-in flag so the fix isn't per-route, and lets us drop the local patch.

🤖 Generated with Claude Code

The relay only falls back to the SPA shell for the invite landing page, and
optionally the bundled git browser. A deployment whose BUZZ_WEB_DIR bundle is a
full client has no way to get client-side routing for its own paths — each one
needs a bespoke predicate compiled into should_serve_spa.

Add BUZZ_WEB_SPA=full: when set, any path the relay does not serve itself falls
back to index.html. Server-owned paths (/api, /git, /hooks, /media, /upload,
/.well-known, /_*, /events, /query, /count, /info, /health, /moderation) keep
returning their own responses, so a mistyped API call still 404s rather than
returning HTML a client would try to parse.

Defaults to false; behaviour with the variable unset is unchanged.

Tests cover the opt-in path, the server-owned 404 list, and default-off.

Signed-off-by: flaukowski <nikolaiflaukowski@gmail.com>
@flaukowski
flaukowski requested a review from a team as a code owner July 26, 2026 20:23
flaukowski added a commit to flaukowski/kannaka-buzz that referenced this pull request Jul 26, 2026
Keeps fork main byte-identical to the upstream branch in block#3027,
so the two do not drift while the PR is in review.

Signed-off-by: flaukowski <nikolaiflaukowski@gmail.com>
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