Skip to content

[SLOP(claude-opus-4-8)] fix(kitchen-sink): serve built frontend from server#5306

Open
MasterPtato wants to merge 1 commit into
mainfrom
stack/slop-claude-opus-4-8-fix-kitchen-sink-serve-built-frontend-from-server-rymmurrk
Open

[SLOP(claude-opus-4-8)] fix(kitchen-sink): serve built frontend from server#5306
MasterPtato wants to merge 1 commit into
mainfrom
stack/slop-claude-opus-4-8-fix-kitchen-sink-serve-built-frontend-from-server-rymmurrk

Conversation

@MasterPtato

Copy link
Copy Markdown
Contributor

No description provided.

@MasterPtato

Copy link
Copy Markdown
Contributor Author

Stack for rivet-dev/rivet

Get stack: forklift get 5306
Push local edits: forklift submit
Merge when ready: forklift merge 5306

@railway-app

railway-app Bot commented Jun 19, 2026

Copy link
Copy Markdown

🚅 Deployed to the rivet-pr-5306 environment in rivet-frontend

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web Jun 19, 2026 at 1:18 am
kitchen-sink 😴 Sleeping (View Logs) Web Jun 19, 2026 at 1:13 am
frontend-cloud 😴 Sleeping (View Logs) Web Jun 19, 2026 at 1:13 am
frontend-inspector 😴 Sleeping (View Logs) Web Jun 19, 2026 at 1:12 am
ladle ✅ Success (View Logs) Web Jun 19, 2026 at 1:08 am
mcp-hub ✅ Success (View Logs) Web Jun 19, 2026 at 1:05 am

@claude

claude Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

PR Review: fix(kitchen-sink): serve built frontend from server

Summary

This PR adds ~20 lines to examples/kitchen-sink/src/server.ts to serve the Vite-built frontend (dist/) from the Node.js/Hono server when the build output is present. A startup-time presence check on dist/index.html makes the new code a no-op during development, activating only in production Docker images where vite build has run.


Findings

Potential Bug: Fragile SPA Fallback Heuristic

examples/kitchen-sink/src/server.ts, lines ~178-182

const last = path.slice(path.lastIndexOf("/") + 1);
if (last.includes(".")) return c.notFound();

This dot-in-filename heuristic returns 404 for any path whose final segment contains a dot, treating it as a "missing static asset." This produces false 404s for valid SPA routes like /users/john.doe or any future path segment that legitimately contains a dot.

The heuristic is unnecessary here: serveStatic already calls next() when a file isn't found, so the fallback handler only runs when the file is genuinely missing. The correct SPA behavior at that point is to unconditionally serve index.html, matching the pattern used in sibling examples:

// examples/react-render/src/server.ts
app.get("/*", (c) => c.html(indexHtml));

Recommendation: Remove the dot check and serve index.html unconditionally on fallback.

Correctness (Positive Notes)

  • Route ordering is correct. serveStatic and the SPA fallback are registered after /api/rivet/* handlers, so API routes are never shadowed.
  • process.cwd() is reliable. The Dockerfile sets WORKDIR /app/examples/kitchen-sink, which matches Vite's default outDir: dist relative to the project root.
  • Startup-time readFileSync is fine. For a production container where index.html is static for the container lifetime, caching it at startup is a reasonable micro-optimization.

Minor: Inconsistency with Sibling Examples

The other examples (react-render, chat-room-render, state-render) use:

app.get("*", serveStatic({ root: "./public", path: "/index.html" }));

The memory-caching approach here is defensible, but the dot-check guard is an unneeded divergence that introduces a correctness hazard.

Security

No concerns. The root parameter to serveStatic is a hardcoded string, not user-controlled. Path traversal protection is the library's responsibility.

Style

Comments are compliant (lowercase complete sentences, no em-dashes). Imports are added at the top of the file. No Rust changes.


Overall Assessment

The feature is correctly structured: presence-guarded, non-intrusive to existing routes, and path resolution is sound. The one issue worth addressing before merge is the dot-based asset heuristic, which can produce unexpected 404s for valid SPA routes with dots in their segments. Replacing it with an unconditional index.html fallback (matching sibling examples) would be more robust with no downside in a Vite SPA context.

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