fix(observer): match /api routes on pathname so ?token= works#49
Merged
Conversation
ObserverServer._handleHttp matched routes against the raw req.url, which includes the query string — so the exact-match routes (`url === "/api/state"` etc.) 404'd whenever a query was present. Result: `/api/state?token=…`, `/api/events?token=…`, `/api/timeline?token=…` returned 404, and token auth only worked via the Authorization header. (Found while adding observer test coverage; flagged in #48, fixed here.) - Parse the pathname once and match all routes on it (dashboard, grid, and every /api/* route). Query parsing for params (start/end/seq) is unchanged. - Update tests/observer-server.test.ts: assert all data routes resolve with ?token= (regression guard), plus the Authorization-header path. Verified: tsc clean, lint 0 problems, 19/19 observer tests pass (stable x2). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up fix for the routing quirk flagged in #48.
ObserverServer._handleHttpmatched routes on the rawreq.url(query string included), sourl === "/api/state"404'd when?token=was present — token auth worked only via the Authorization header. Now all routes match on the parsed pathname, so?token=resolves consistently.?token=+ the header path.tsc clean · lint 0 · 19/19 observer tests pass (stable ×2).
🤖 Generated with Claude Code