Skip to content

fix(frontend): point dev chessServerURL at chessServer on 3001 (B2) - #269

Merged
sweksha-cloud merged 3 commits into
mainfrom
fix/chess-server-dev-url
Oct 9, 2026
Merged

sweksha-cloud merged 3 commits into
mainfrom
fix/chess-server-dev-url

Conversation

@sweksha-cloud

@sweksha-cloud sweksha-cloud commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

B2 from the Saved Games, B2 and PR Cleanup Plan (v8). In development, chessServerURL pointed at port 8080, which is stockfishServer. chessServer runs on 3001. This points it at 3001.

That alone would break the AI tutor: StockfishTutor.tsx read chessServerURL before stockfishServerURL for its /api/analyze call, and it only worked because both were 8080. So this PR also carries @ToldYO's two tutor fixes from #215, which make the tutor use stockfishServerURL only.

Type of Change

  • New feature
  • Bug fix
  • Refactor
  • Documentation update
  • Style/UI update
  • Performance improvement
  • Other (please specify):

Key Changes

Testing

  • Unit tests added/updated

  • Integration tests added/updated

  • Manual testing performed

  • All tests pass

  • Frontend: 155/155 tests pass, tsc --noEmit reports 0 errors (on current main, cc637f9).

  • Routing check, with chessServer and stockfishServer run directly with Node (not docker, see below) and a socket.io client sending the same events the pages send:

    • Puzzle: newPuzzle on chessServer returns host (student seat).
    • Lesson: newgame then move e2-e4 on chessServer updates the board.
    • Tutor: POST /api/analyze on stockfishServer (8080) returns 200 with success: true. The same request to chessServer returns 404, which is why the tutor fix has to ship with the port change.

B2.2 check: backend in docker, frontend in dev mode

The frontend Docker image is always a production build (npm run build), which reads environment.prod.js, never environment.js. So a fully dockerized run can't exercise this change. The check ran the backend from deploy/dev in docker (Mongo, middleware, chessServer on 3001, stockfishServer moved to 8080 to match environment.js) and the frontend with npm start, driven by a headless browser that logged every socket and request.

Plan check Result
Puzzles connect to 3001 Pass. Websocket to localhost:3001, newPuzzle answered with host, and the puzzle's move and lastmove go to chessServer.
Tutor analysis goes to 8080 Pass. After a move in Play Computer, the tutor calls POST localhost:8080/api/analyze and gets 200 with an analysis.
A lesson move reaches chessServer Can't pass on current main, not caused by this PR (details below). Lessons do now open their game socket on localhost:3001.

Lessons: two existing problems found during the check

  1. Lessons never start a game on chessServer. Lesson-overlay.tsx sends setstateColor without ever sending newgame, so chessServer replies "game not found for this socket". Before this PR, the same messages went to stockfishServer on 8080, which ignored them, so lessons had no server-side game before either. Lessons need to call startNewGame() first; that's a separate fix.
  2. Lesson routes read the wrong database locally. getDb() in routes/lessons.js and routes/activities.js is hardcoded to the ystem database, but the dev stack stores data in ystem_dev (from MONGO_URI), so /lessons/getTotalPieceLesson returns 500. It's the same hardcoded-name bug fixed for users.js in Puzzle themes #150.

Both happen identically with the old 8080 value, so this PR doesn't regress lessons.

Follow-up

@sweksha-cloud
sweksha-cloud requested a review from ToldYO October 9, 2026 12:19

@ToldYO ToldYO left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: LGTM 👍

Thanks for putting this together! The changes look solid and address item B2 cleanly.

Key Highlights & Verification:

  • Port Alignment: chessServer correctly runs on port 3001 (as configured in chessServer/src/index.js and docker-compose.yml), while stockfishServer handles analysis on port 8080.
  • Decoupling in StockfishTutor.tsx: Restricting rawBase in StockfishTutor to stockfishServerURL / stockfishServer is essential here. Previously, it preferred urls.chessServerURL (which only worked when chessServerURL was erroneously pointed to 8080). Directing analysis traffic to stockfishServerURL ensures POST requests to /api/analyze hit the correct server instead of 404ing against chessServer on 3001.
  • Test Suite: Ran frontend tests locally (npm test -- --watchAll=false in react-ystemandchess) — all 30/30 test suites passed (155 tests total).

Minor Nitpick:

  • In react-ystemandchess/src/environments/environment.js, there's a missing trailing newline at the end of the file (\ No newline at end of file). Adding a newline at EOF would keep git diffs clean.

Note on Merge:

Since this branch contains commits from both contributors, please make sure the squash commit message includes the co-author trailer:

Co-authored-by: Ahmad Nakhala <ahmadnakhala2004@gmail.com>
Co-authored-by: sweksha-cloud <swekshas123@gmail.com>

@sweksha-cloud
sweksha-cloud merged commit 9f3bcd9 into main Oct 9, 2026
1 check passed
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.

2 participants