[Bug] Workshop stuck on INITIALIZING due to SPA routing of /api/ws #36
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Description
The Timmy Tower Workshop, deployed at
alexanderwhitestone.com/tower, consistently displays an "INITIALIZING" state and fails to connect to the backend WebSocket service. Investigation reveals that the Single Page Application (SPA) routing for/toweris inadvertently intercepting API calls directed to/api/ws, preventing the WebSocket connection from being established.This issue directly impacts user experience, as the core functionality of the Workshop remains inaccessible, and users receive no feedback regarding the connection failure.
Reproduction Steps
alexanderwhitestone.com/tower./api/wsare likely failing or being misrouted.Expected Behavior
The Workshop should successfully establish a WebSocket connection to the backend, display agent activity, and enable chat interactions. API calls to
/api/wsshould be correctly routed to the backend service, bypassing the SPA routing for static assets.Technical Details
replit/timmy-towerartifacts/api-server/src/app.ts: This file defines the Express application routing. Lines 81-82 handle the/towerroute, servingindex.htmlfor all sub-paths. This might be over-eagerly catching/tower/apirequests.the-matrix/js/websocket.js: This frontend file attempts to establish the WebSocket connection toWS_URL, which resolves to/api/wsrelative to the host.app.get("/tower/*splat")rule is likely catching/tower/api/wsrequests, causing them to be served theindex.htmlinstead of being routed to the actual API endpoint.Proposed Solution
Modify the Express routing in
artifacts/api-server/src/app.tsto ensure that requests to/api/*(including/api/ws) are explicitly handled by the API router before the/towerstatic file serving and SPA fallback rule. This may involve reorderingapp.use("/api", router);or adding a more specific exclusion for API routes within the/towerhandling.Labels
bug,frontend,backend,routing,websocketPR created: http://143.198.27.163:3000/replit/timmy-tower/pulls/81
The
/tower/*splatSPA fallback in Express 5 was catching all sub-paths including/tower/api/ws, servingindex.htmlinstead of letting the request reach the WebSocket server. Added a guard that callsnext()for paths starting withapi/so they fall through to the API router / ws server.