You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
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:
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.