Skip to content

fix(observer): match /api routes on pathname so ?token= works#49

Merged
xcodethink merged 1 commit into
mainfrom
fix/observer-api-routing
Jun 2, 2026
Merged

fix(observer): match /api routes on pathname so ?token= works#49
xcodethink merged 1 commit into
mainfrom
fix/observer-api-routing

Conversation

@xcodethink

Copy link
Copy Markdown
Owner

Follow-up fix for the routing quirk flagged in #48.

ObserverServer._handleHttp matched routes on the raw req.url (query string included), so url === "/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.

  • Query param parsing (start/end/seq) unchanged.
  • Regression test: all data routes resolve with ?token= + the header path.

tsc clean · lint 0 · 19/19 observer tests pass (stable ×2).

🤖 Generated with Claude Code

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>
@xcodethink xcodethink merged commit 8b7d970 into main Jun 2, 2026
8 of 11 checks passed
@xcodethink xcodethink deleted the fix/observer-api-routing branch June 2, 2026 16:02
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