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

@MasterPtato MasterPtato commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@MasterPtato

MasterPtato commented Jun 19, 2026

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)
frontend-cloud 😴 Sleeping (View Logs) Web Jun 23, 2026 at 3:14 pm
website 😴 Sleeping (View Logs) Web Jun 22, 2026 at 10:52 pm
kitchen-sink 😴 Sleeping (View Logs) Web Jun 20, 2026 at 10:32 pm
frontend-inspector 😴 Sleeping (View Logs) Web Jun 20, 2026 at 9:21 pm
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

This PR adds SPA static-file serving to the kitchen-sink server: at startup it checks for a dist/ directory (emitted by a Vite build), mounts serveStatic to serve its assets, and wires a custom fallback handler that serves index.html for non-asset paths.


Bug — SPA fallback breaks routes with dots in path segments

examples/kitchen-sink/src/server.ts:179

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

The heuristic that treats any final path segment containing . as an "asset" returns 404 for SPA routes like /users/john.doe, /v1.0/dashboard, or any route with a dot in a path parameter — even though the SPA shell should be returned. Vite already fingerprints its output files (/assets/vendor-AbCd1234.js), so there is a simpler approach: serveStatic already calls next() when it cannot find a file. Replacing the entire hand-rolled fallback with the established pattern used elsewhere in this repo removes the heuristic entirely:

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

Simplification — Hand-rolled SPA fallback duplicates existing pattern

examples/kitchen-sink/src/server.ts:177–184

The 8-line custom handler (URL parsing, dot heuristic, readFileSync at startup) reimplements what serveStatic({ root: distDir, path: "/index.html" }) does natively. The one-liner form is used in every other server example in the repo (state-render, stream-render, etc.) and has no edge-case bugs. Recommend switching to the canonical form.


Simplification — new URL(c.req.url).pathname vs c.req.path

examples/kitchen-sink/src/server.ts:178

Hono's HonoRequest exposes c.req.path which is already the parsed pathname — no URL object allocation needed. (Resolved automatically if the SPA fallback is replaced as above.)


Minor convention — First comment line explains WHAT, not WHY

examples/kitchen-sink/src/server.ts:170

// Serve the built frontend when it is present. The Vite build emits `dist/`,
// which only exists in production images, so dev runs skip this branch.

Per CLAUDE.md: "Don't explain WHAT the code does." The first sentence is redundant with the code. The second sentence (the WHY) is the useful one — drop the first and keep: // The Vite build emits dist/ only in production images, so dev runs skip this branch.


Overall: The approach is sound — guard on existsSync, register static middleware before the SPA fallback. The main actionable item is replacing the hand-rolled fallback with serveStatic({ path: "/index.html" }) to fix the dot-in-path bug and eliminate ~8 lines of custom code.

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