Skip to content

Fix allstrides frontend dev proxy port and broken smoke test - #63

Open
rootkiller6788 wants to merge 1 commit into
google:mainfrom
rootkiller6788:fix-allstrides-frontend-test-proxy
Open

Fix allstrides frontend dev proxy port and broken smoke test#63
rootkiller6788 wants to merge 1 commit into
google:mainfrom
rootkiller6788:fix-allstrides-frontend-test-proxy

Conversation

@rootkiller6788

Copy link
Copy Markdown

What

Two fixes for the allstrides example frontend developer tooling, both found by inspecting the code (no issue was filed).

1. Dev proxy targets a dead port

examples/allstrides/frontend/src/setupProxy.js proxies /api (with ws: true) to http://127.0.0.1:8000. That port is a leftover from the original Python FastAPI backend this app was migrated off of. The TypeScript/Express server listens on 8080 by default (server/src/index.ts), and every other artifact in the example agrees (README.md, Dockerfile, docker-compose.yml, start_allstrides.sh). A port search confirms 8000 appears nowhere else in the example. When running the CRA dev server (npm start in frontend/), all API calls and WebSocket upgrades fail with connection refused.

2. The frontend test suite cannot run at all

npm test was completely broken under the pinned react-scripts@5 (jest 27):

  • App.test.tsx was still the default CRA smoke test asserting "learn react", which the rewritten app never renders.
  • react-router-dom@7 ships an exports-only package (its declared main: ./dist/main.js is absent from the published tarball), which jest 27's resolver cannot load.
  • axios@1.13 ships an ESM-only main, which jest 27 cannot require either.

The fix pins react-router-dom to the v6 line (the app uses only v6-compatible APIs), maps axios to its CommonJS build via the jest config in package.json, and updates the smoke test to assert the real landing page heading (Welcome to AllStrides).

Verification

  • CI=true npx react-scripts test --watchAll=falsePASS (1 suite, 1 test)
  • npm run buildsucceeds (production build unchanged)
  • Port mismatch confirmed statically: 8000 appears only in setupProxy.js; 8080 is the default in server/src/index.ts:40 and every config file.

Scope

examples/allstrides/frontend/ only: src/setupProxy.js, src/App.test.tsx, package.json, package-lock.json.

The CRA dev proxy (src/setupProxy.js) still targets port 8000, which
was left over from the pre-migration Python backend. The TypeScript
Express server listens on 8080 (see index.ts, README, Dockerfile and
docker-compose.yml), so all /api calls and WebSocket upgrades fail in
frontend dev mode. Point the proxy at 127.0.0.1:8080.

Also fix the frontend test suite, which could not run at all:
- App.test.tsx still asserted the default CRA "learn react" text that
  no longer exists; assert the actual landing page heading instead.
- react-router-dom is pinned to v6 and axios is mapped to its CommonJS
  build in the jest config because react-scripts 5 uses jest 27, which
  cannot resolve the exports-only/ESM packaging of react-router-dom v7
  and axios 1.13. The app only uses v6-compatible APIs (BrowserRouter,
  Routes, Route, Link, useNavigate, useParams).

Verified: CI=true npx react-scripts test --watchAll=false passes and
npm run build succeeds.
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