fix: serve built SPA from dist when web-server runs from source#9
Conversation
npm run ui (tsx src/ui) resolved the static dir to src/ui/public, which has no index.html (vite build emits it to dist/ui/public), causing ENOENT on page load. Fall back to the built output when running from source.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesFrontend static directory resolution
🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
npm run ui(tsx src/ui/web-server.ts) booted fine but 500'd on first page load:The server resolves its static dir relative to its own file (
__dirname/public). Running from source that'ssrc/ui/public, which only holds static assets — the SPAindex.htmlis emitted byvite buildintodist/ui/public. So the dev server had noindex.htmlto serve. (Prod,node dist/ui/web-server.js, was always fine.)Fix
Resolve
publicDironce: use__dirname/publicwhen it containsindex.html, otherwise fall back to the builtdist/ui/public. Bothexpress.staticand the SPA fallback route now use it. Prod behavior is unchanged;npm run uinow works after a build.Verify
tsc --noEmit: cleanSummary by CodeRabbit