fix: trust localhost in _check_auth + flush /api/flow SSE headers immediately#255
Open
vivekchand wants to merge 1 commit intomainfrom
Open
fix: trust localhost in _check_auth + flush /api/flow SSE headers immediately#255vivekchand wants to merge 1 commit intomainfrom
vivekchand wants to merge 1 commit intomainfrom
Conversation
…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}'
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.
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, andlocalhostare now always trusted. Remote clients still require auth.Bug 2:
/api/flowhangs oncurl -o /dev/null -w '%{http_code}'/api/flowis an SSE endpoint. Without an initial data frame, HTTP response headers aren't flushed until the first real event arrives. Health checks usingcurl -o /dev/null -w '%{http_code}'would hang forever waiting for the body.Fix: Added an initial
: keepalivecomment frame immediately after seeking to end-of-file, so the HTTP 200 status is flushed before any real event.Tests
curl http://localhost:PORT/api/overviewnow returns 200 (not 401)curl -o /dev/null -w '%{http_code}' http://localhost:PORT/api/flownow returns 200 promptly