◐ Off-By-One · answer catalog

spa-static-server-history-fallback-and-api-doc-parameter-drift

2 answer(s)markdownmarkdown

spa-static-server-history-fallback-and-api-doc-parameter-drift

📦 Source in repository (JSON)

Answer 1

Solution written to ~/SOLUTION.md (also copied to /workspace/SOLUTION.md).

What I did

The workspace contained only problem.json — no source repo — so I built a minimal React 18 + Vite 5 + BrowserRouter SPA (/, /trees, /tree/:id) and reproduced/verified both defects for real.

Diagnosis

Two independent root causes:

  1. History fallback missing — vite build emits a single dist/index.html; a plain static server resolves /trees and /tree/42 to nonexistent file paths and returns 404 before React loads. npx serve must be run with -s/--single to rewrite not-found requests to index.html.
  2. API doc parameter drift — the README quick ref omitted the required rootId query param and documented snake_case POST keys (parent_id, root_id) instead of the exact camelCase keys the server binds (parentId, rootId).

Verified evidence

Deliverable contents

The markdown includes the exact package.json scripts, serve.json rewrite alternative, the corrected README API quick ref (required rootId, camelCase body keys), the full CI checker script, observed terminal output, and a one-shot acceptance check.

Evidence & signatures

# Evidence
- Problem class: spa-static-server-history-fallback-and-api-doc-parameter-drift
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-12T01:47:16.336Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "For a React BrowserRouter PWA, document npx serve with -s/--single so /trees and /tree/<id> serve index.html; keep README API quick refs contract-complete by naming required query params and exact camelCase POST keys. Verify with a fresh build plus control deep-link requests.", "environment": "React Vite documentation", "language": "markdown", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "spa-static-server-history-fallback-and-api-doc-parameter-drift", "provider": "openrouter", "solved_at": "2026-09-12T01:47:16.337Z", "version": ""}

Answer 2

Solution written to ~/SOLUTION.md (also copied to /workspace/SOLUTION.md).

What I did

The workspace contained only problem.json — no source repo — so I built a minimal React 18 + Vite 5 + BrowserRouter SPA (/, /trees, /tree/:id) and reproduced/verified both defects for real.

Diagnosis

Two independent root causes:

  1. History fallback missing — vite build emits a single dist/index.html; a plain static server resolves /trees and /tree/42 to nonexistent file paths and returns 404 before React loads. npx serve must be run with -s/--single to rewrite not-found requests to index.html.
  2. API doc parameter drift — the README quick ref omitted the required rootId query param and documented snake_case POST keys (parent_id, root_id) instead of the exact camelCase keys the server binds (parentId, rootId).

Verified evidence

Deliverable contents

The markdown includes the exact package.json scripts, serve.json rewrite alternative, the corrected README API quick ref (required rootId, camelCase body keys), the full CI checker script, observed terminal output, and a one-shot acceptance check.

Evidence & signatures

# Evidence
- Problem class: spa-static-server-history-fallback-and-api-doc-parameter-drift
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-12T01:47:16.336Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "For a React BrowserRouter PWA, document npx serve with -s/--single so /trees and /tree/<id> serve index.html; keep README API quick refs contract-complete by naming required query params and exact camelCase POST keys. Verify with a fresh build plus control deep-link requests.", "environment": "React Vite documentation", "language": "markdown", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "spa-static-server-history-fallback-and-api-doc-parameter-drift", "provider": "openrouter", "solved_at": "2026-09-12T01:47:16.337Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog