Skip to content

fix(main): serve /kds-standalone in SPA fallback - #1135

Merged
khaira777 merged 4 commits into
mainfrom
fm/flocafe-issue-1096-r1
Oct 14, 2026
Merged

khaira777 merged 4 commits into
mainfrom
fm/flocafe-issue-1096-r1

Conversation

@khaira777

@khaira777 khaira777 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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 /kds prefix exclusion boundary in the SPA fallback so /kds-standalone (and /kds-standalone/) is served by the SPA fallback while /kds and /kds/... remain excluded, preserving API/WebSocket exclusions and path containment. Deliver via the no-mistakes pipeline as its own PR with Fixes #1096 in the PR summary.

What Changed

  • Bound the /api and /kds negative lookahead prefixes in the main/server.ts SPA fallback route (/^(?!\/api(?:\/|$)|\/kds(?:\/|$)).*$/) to segment boundaries (/ or end-of-path) so /kds-standalone and /kds-standalone/ resolve to their exported static page while /kds, /kds/*, and /api/* remain excluded.
  • Updated docs/architecture/desktop-build.md to reflect the segment-bounded catch-all route regex.
  • Extended tests/static-route-resolution.test.ts with 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.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Navigating to GET /kds-standalone on the main server returns HTTP 200 with the exported kds-standalone/index.html page and renders the standalone KDS UI in Chromium ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/kds-standalone-main-server.png
Navigating to GET /kds-standalone/ (with trailing slash) on the main server returns HTTP 200 with the exported kds-standalone/index.html page ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
Requesting HTTP GET /kds or GET /kds/orders on the main server remains excluded from the SPA fallback with HTTP 404 while WebSocket upgrades on /kds continue to connect ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
Requesting an unknown /api/* route (GET /api/auth/nonexistent) remains excluded from the SPA fallback and returns HTTP 404 instead of index.html ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
Adversarial path traversal requests (e.g. /%2e%2e/package.json and /../outside) remain contained within frontend/out and fall back safely to root index.html without leaking files outside the export di… ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json

Standalone KDS page rendered from main server at /kds-standalone

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" } ]

[
  {
    "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"
  },
  {
    "label": "Browser render of /kds-standalone on main server",
    "urlPath": "/kds-standalone",
    "status": 200,
    "contentType": "text/html; charset=utf-8",
    "detail": "Rendered KdsStandalonePage component in Chromium; visible text: \"Kitchen Display\\n\\nSign in with your kitchen staff account\\n\\nEmail\\nPassword\\nKeep me logged in\\nSign In\\n\\nOnly chef, manager, or owner roles can access the kitchen display.\"",
    "screenshotPath": "~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/kds-standalone-main-server.png"
  }
]

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.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Navigating to GET /kds-standalone on the main server returns HTTP 200 with the exported kds-standalone/index.html page and renders the standalone KDS UI in Chromium ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/kds-standalone-main-server.png
Navigating to GET /kds-standalone/ (with trailing slash) on the main server returns HTTP 200 with the exported kds-standalone/index.html page ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
Requesting HTTP GET /kds or GET /kds/orders on the main server remains excluded from the SPA fallback with HTTP 404 while WebSocket upgrades on /kds continue to connect ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
Requesting an unknown /api/* route (GET /api/auth/nonexistent) remains excluded from the SPA fallback and returns HTTP 404 instead of index.html ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
Adversarial path traversal requests (e.g. /%2e%2e/package.json and /../outside) remain contained within frontend/out and fall back safely to root index.html without leaking files outside the export di… ✅ pass live ~/.no-mistakes/evidence/01M4W1FZW6Z04WK9XS22MZS55N/live-route-verification.json
  • npm run test:static-routes
  • npm run test:desktop-trailing-slash-routing
  • npm run build:frontend && npm run build
  • node 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.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0effb39f-5ed7-409f-9f20-d93f68cb5445

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaira777

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Adjusts static route matching to include a new frontend path.

The routing fix appears safe to merge, with a non-blocking test cleanup issue.

Findings

  1. P2 Failed startup leaves temporary files ▶

Summary

The main server now serves /kds-standalone and /kds-standalone/ through its static-page fallback.

  • The main server serves the standalone KDS page at both URL forms.

Validation was limited to code inspection; no tests or browser checks were run during this review.

Reviews (1) · Last reviewed commit: "no-mistakes(document): Update SPA fallba..." · Reviewed by Greptile

Comment thread tests/static-route-resolution.test.ts Resolved
@khaira777 khaira777 changed the title fix(main): serve /kds-standalone in static route fallback fix(server): serve /kds-standalone in SPA fallback Oct 14, 2026
@khaira777 khaira777 changed the title fix(server): serve /kds-standalone in SPA fallback fix(main): serve /kds-standalone in SPA fallback Oct 14, 2026
@khaira777
khaira777 force-pushed the fm/flocafe-issue-1096-r1 branch from 4141146 to 74be44b Compare October 14, 2026 01:56
@khaira777 khaira777 changed the title fix(main): serve /kds-standalone in SPA fallback fix(main): serve /kds-standalone in static SPA fallback Oct 14, 2026
@khaira777 khaira777 changed the title fix(main): serve /kds-standalone in static SPA fallback fix(server): serve /kds-standalone in SPA fallback Oct 14, 2026
@khaira777 khaira777 changed the title fix(server): serve /kds-standalone in SPA fallback fix(main): serve /kds-standalone in SPA fallback Oct 14, 2026
…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`
@khaira777
khaira777 force-pushed the fm/flocafe-issue-1096-r1 branch from 74be44b to 33d9a58 Compare October 14, 2026 02:11
@khaira777
khaira777 enabled auto-merge (squash) October 14, 2026 02:11
@khaira777
khaira777 merged commit 9088dc8 into main Oct 14, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-issue-1096-r1 branch October 14, 2026 02:17
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.

fix(server): adjust server router regex to allow /kds-standalone route on port 3001

1 participant