Backend error #25
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?
The backend does not start it gives this error:
The error is at line 65:
foundryCorsPathsis undefined. Let me check the git history to understand how this happened.Now let me verify the fix — syntax check, confirm no other stale references exist, and do a quick functional smoke test of the middleware logic:
No stale references remain. Let me smoke-test the actual middleware by booting the server and hitting routes — checking whether a missing Mongo would block it first:
connectDBexits on failure, butapp.listenruns immediately and mongoose takes ~30s to time out — enough of a window to curl. Let me check for a local mongod first, then boot and test:Dependencies installed. Now boot the backend and exercise the failing request path:
Fixed. The backend crash was a leftover variable name from a refactor in
backend/src/index.js.Root cause: The commit that introduced the shared open-CORS handling for service link/sync routes defined the path list as
openCorsPaths(line 46) and appliedopenCorsto it, but the guard middleware that skips the restrictive app-wide CORS for those same paths still referenced the old namefoundryCorsPaths(line 65). That name was never defined, so every request passing through the middleware threwReferenceError: foundryCorsPaths is not defined→ HTTP 500 — matching the reported stack trace (index.js:65:3→Layer.handleRequest→ … →cookieParser).Fix: one-line rename to the defined variable:
Verification (ran the real server before and after):
GET /api/testreturned HTTP 500 with the exact stack trace from the issue.OPTIONSpreflight on/api/foundry/sync/*from a foreign origin gets the open CORS headers (Access-Control-Allow-Origin: <origin>,Authorization+ bot-secret header allowed) and is not overwritten by the restrictive CORS — the guard's whole purpose./api/campaign/list) still goes throughappCorsas before.grepconfirms no other stalefoundryCorsPathsreferences remain anywhere in the repo.npm test: 34/34 pass (existing suite covers the Foundry module sync logic; the repo has no backend HTTP test harness, so verification was done by booting the actual server rather than adding unrelated infrastructure for a one-line rename).Implementation is ready for review: #26