Repository navigation
fix(main): serve /kds-standalone in SPA fallback - #1135
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
@greptile review |
|
4141146 to
74be44b
Compare
…nux)` (and downstream `Required Checks Gate`) by formatting `tests/static-route-resolution.test.ts` with `oxfmt` (`npx oxfmt --write -- main/server.ts tests/static-route-resolution.test.ts`). Verified locally with `node scripts/ci/check-changed-format.cjs --base 285dd32`, `npm run lint`, `npm run lint:budget`, `npm run build`, `npm run docs:check`, `npx tsx tests/static-route-resolution.test.ts`, and `git diff --check`
74be44b to
33d9a58
Compare
Fixes #1096
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1096 ("Main server SPA fallback returns 404 for /kds-standalone due to prefix check"): in
main/server.ts, fix the/kdsprefix exclusion boundary in the SPA fallback so/kds-standalone(and/kds-standalone/) is served by the SPA fallback while/kdsand/kds/...remain excluded, preserving API/WebSocket exclusions and path containment. Deliver via theno-mistakespipeline as its own PR withFixes #1096in the PR summary.What Changed
/apiand/kdsnegative lookahead prefixes in themain/server.tsSPA fallback route (/^(?!\/api(?:\/|$)|\/kds(?:\/|$)).*$/) to segment boundaries (/or end-of-path) so/kds-standaloneand/kds-standalone/resolve to their exported static page while/kds,/kds/*, and/api/*remain excluded.docs/architecture/desktop-build.mdto reflect the segment-bounded catch-all route regex.tests/static-route-resolution.test.tswith unit and live HTTP assertions covering/kds-standalone,/kds-standalone/,/kds,/kds/orders, and/api/auth/nonexistent.Fixes #1096
Risk Assessment
✅ Low: Surgical regex boundary refinement in the Express SPA fallback route with matching documentation and end-to-end HTTP route resolution tests.
Testing
Built the static Next.js frontend export and backend, stood up the real Express/WebSocket main server against an isolated SQLite database, drove HTTP, WebSocket, and headless Chromium checks across /kds-standalone, /kds-standalone/, /kds, /kds/orders, /api/auth/nonexistent, and path-traversal inputs, captured a browser screenshot and JSON verification log in the evidence directory, and ran the focused static-route and trailing-slash test suites; all scenarios and tests passed.
Evidence: Live HTTP, WebSocket, and browser route verification transcript
[ { "label": "Scenario 1: GET /kds-standalone serves exported kds-standalone/index.html", "urlPath": "/kds-standalone", "status": 200, "contentType": "text/html; charset=utf-8", "detail": "HTTP 200 with exact frontend/out/kds-standalone/index.html (13936 bytes)" }, { "label": "Scenario 2: GET /kds-standalone/ (with trailing slash) serves exported kds-standalone/index.html", "urlPath": "/kds-standalone/", "status": 200, "contentType": "text/html; charset=utf-8", "detail": "HTTP 200 with exact frontend/out/kds-standalone/index.html (13936 bytes)" }, { "label": "Scenario 3a: GET /kds remains excluded from SPA fallback (404)", "urlPath": "/kds", "status": 404, "contentType": "text/html; charset=utf-8", "detail": "HTTP 404 (excluded from SPA fallback)" }, { "label": "Scenario 3b: GET /kds/orders remains excluded from SPA fallback (404)", "urlPath": "/kds/orders", "status": 404, "contentType": "text/html; charset=utf-8", "detail": "HTTP 404 (excluded from SPA fallback)" }, { "label": "Scenario 3c: WebSocket upgrade on ws://127.0.0.1:62174/kds remains active", "urlPath": "/kds (WebSocket)", "status": 101, "contentType": "websocket", "detail": "Received WebSocket message: {"type":"connected","message":"Connected to Flo KDS","timestamp":"2026-10-14T01:54:38.536Z"}" }, { "label": "Scenario 4: GET /api/auth/nonexistent remains excluded from SPA fallback (404)", "urlPath": "/api/auth/nonexistent", "status": 404, "contentType": "text/html; charset=utf-8", "detail": "HTTP 404 (excluded from SPA fallback)" }, { "label": "Scenario 5: Adversarial path traversal /%2e%2e/package.json stays contained inside frontend/out", "urlPath": "/%2e%2e/package.json", "status": 200, "contentType": "text/html; charset=utf-8", "detail": "Contained inside frontend/out; fell back to root index.html without leaking package.json" } ]Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:static-routesnpm run test:desktop-trailing-slash-routingnpm run build:frontend && npm run buildnode tests/run-electron-node-test.cjs <live-server-and-chromium-e2e-verification>✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.