Repository navigation
web: open SSE streams same-origin so the session cookie reaches them (c-13e86c) - #41
Merged
Merged
Conversation
…(c-13e86c) Since the session moved to an HttpOnly cookie, getToken() returns null, but sseUrl still sent non-production builds (next dev) straight to <host>:8787. That cross-origin EventSource carries no cookie and no token, so every connect answered 401 and the Sessions tab showed Reconnecting. Other calls went through the same-origin /api rewrite and worked. Predates E5. - web/src/lib/sse.ts: sseUrl is always a same-origin /api/ path (throws otherwise); NEXT_PUBLIC_SSE_BASE is removed (a cross-origin stream cannot present the cookie, and CORS '*' forbids credentials). - next.config.mjs: compress:false in dev, measured: with a browser's Accept-Encoding the rewrite gzips and buffers the stream; without compression frames arrive as sent. - server: PG test signs in through the login handler as the bootstrap ARTEX admin and as a console user, then opens the activity stream with only the cookie and reads a frame; no session -> 401. Co-Authored-By: Claude Opus 5.5 <[email protected]>
streamActivity and streamLogs flushed only headers until the first event or the 20 s ping. The Next.js dev rewrite passes headers on only with a first body byte, so the EventSource stayed unopened and the Sessions tab showed Reconnecting for 20 s on an idle task (measured: TTFB 20.0 s through next dev, immediate direct). openSSE sets the SSE headers and writes ': open'. The PG test now asserts the comment is the first line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # HANDOFF.md
…state fits Co-Authored-By: Claude Opus 5.5 <[email protected]>
…doff/ Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Refs #31
Why
Task activity stream answers 401 after a UI login on the E5 stack
Seen during the c-01377e live check (branch
ej/20261124-140004-61d777, which merges c-f4115c + c-869050 on main): after logging in through the console form as the legacyARTEXadmin,GET /api/exploration/activity/stream?task=N&since=…answers 401 repeatedly and the Sessions tab shows "Reconnecting". Other API calls with the same session succeed.What changed
web: open SSE streams same-origin so the session cookie reaches them (c-13e86c) (ad7d883)
Since the session moved to an HttpOnly cookie, getToken() returns null, but
sseUrl still sent non-production builds (next dev) straight to :8787.
That cross-origin EventSource carries no cookie and no token, so every
connect answered 401 and the Sessions tab showed Reconnecting. Other calls
went through the same-origin /api rewrite and worked. Predates E5.
otherwise); NEXT_PUBLIC_SSE_BASE is removed (a cross-origin stream cannot
present the cookie, and CORS '*' forbids credentials).
Accept-Encoding the rewrite gzips and buffers the stream; without
compression frames arrive as sent.
ARTEX admin and as a console user, then opens the activity stream with
only the cookie and reads a frame; no session -> 401.
server: SSE streams send a first comment when they open (c-13e86c) (b89fab2)
streamActivity and streamLogs flushed only headers until the first event or
the 20 s ping. The Next.js dev rewrite passes headers on only with a first
body byte, so the EventSource stayed unopened and the Sessions tab showed
Reconnecting for 20 s on an idle task (measured: TTFB 20.0 s through next
dev, immediate direct). openSSE sets the SSE headers and writes ': open'.
The PG test now asserts the comment is the first line.
HANDOFF: c-13e86c state, gotchas, decision (cd64413)
HANDOFF: condense the E5 entry to its on-main state (E5: engagement authorization artifact in the target gate, hash-chained audit schema #31) so Current state fits (d228f19)
HANDOFF: move the 2026-11-23 audit's operator-facing list to docs/handoff/ (dc77cdc)
HANDOFF: deltas stamp (c-13e86c) (4f13c18)
Files changed
Tests touched:
server/activity_stream_auth_pg_test.go,web/src/lib/sse.test.mjs15 files, +303 −141
server/activity_stream_auth_pg_test.goHANDOFF.mddocs/handoff/2026-11-23-security-audit-operator-changes.mdweb/src/lib/api.tsserver/sse_open.goweb/src/lib/sse.tsweb/src/lib/sse.test.mjsserver/server.goREADME.mdweb/next.config.mjsweb/package.jsonweb/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsxweb/src/app/(main)/system/logs/page.tsxweb/src/hooks/use-side-questions.tsscripts/verify.shOpened by Composite ·
ej/20261124-142817-7e3c57→main· cardc-13e86c· run20261124-142817-7e3c57🤖 Generated with Claude Code
Summary by cubic
Fixes the activity stream answering 401 after a console login: the HttpOnly session cookie never reached the cross-origin EventSource that
sseUrlbuilt in dev builds, so every connect was unauthenticated./api/paths;NEXT_PUBLIC_SSE_BASEis removed.openSSEwrites a: opencomment so proxies that wait for a first body byte pass the headers through immediately.Written for commit 4f13c18. Summary will update on new commits.