Skip to content

fix: trust localhost in _check_auth + flush /api/flow SSE headers immediately#255

Open
vivekchand wants to merge 1 commit intomainfrom
fix/e2e-localhost-auth-bypass-20260320
Open

fix: trust localhost in _check_auth + flush /api/flow SSE headers immediately#255
vivekchand wants to merge 1 commit intomainfrom
fix/e2e-localhost-auth-bypass-20260320

Conversation

@vivekchand
Copy link
Owner

Summary

Two E2E health check failures fixed:

Bug 1: API endpoints return 401 for localhost health checks

_check_auth() required a Bearer token for all /api/* requests, including those from localhost. This broke E2E tests, local monitoring, and any tooling running on the same machine.

Fix: Added localhost bypass — 127.0.0.1, ::1, and localhost are now always trusted. Remote clients still require auth.

Bug 2: /api/flow hangs on curl -o /dev/null -w '%{http_code}'

/api/flow is an SSE endpoint. Without an initial data frame, HTTP response headers aren't flushed until the first real event arrives. Health checks using curl -o /dev/null -w '%{http_code}' would hang forever waiting for the body.

Fix: Added an initial : keepalive comment frame immediately after seeking to end-of-file, so the HTTP 200 status is flushed before any real event.

Tests

  • E2E: curl http://localhost:PORT/api/overview now returns 200 (not 401)
  • E2E: curl -o /dev/null -w '%{http_code}' http://localhost:PORT/api/flow now returns 200 promptly

…headers immediately

- Add localhost bypass in _check_auth() so health checks and E2E tests
  can hit /api/* without needing a Bearer token (127.0.0.1, ::1 trusted)
- Send initial SSE keepalive in /api/flow generate() so HTTP 200 status
  is flushed before any real event arrives (fixes curl health checks timing out)

Fixes E2E test: API endpoints returning 401 for local health checks
Fixes E2E test: /api/flow hanging on curl -o /dev/null -w '%{http_code}'
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