fix(topology): send auth token on discover stream requests

The SSE discover endpoint used raw fetch without Authorization, so login sessions got unauthorized after auth was enabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hansjone 2026-07-30 02:34:25 +00:00
parent a3bdad5be1
commit 325bce0413

View file

@ -563,15 +563,20 @@ export async function discoverTopologyNeighborsStream(
handlers: TopologyDiscoverStreamHandlers, handlers: TopologyDiscoverStreamHandlers,
signal?: AbortSignal, signal?: AbortSignal,
): Promise<TopologyDiscoverOut> { ): Promise<TopologyDiscoverOut> {
const res = await fetch(`/v1/topology/maps/${encodeURIComponent(mapId)}/discover/stream`, { const path = `/v1/topology/maps/${encodeURIComponent(mapId)}/discover/stream`;
const res = await fetch(path, {
method: "POST", method: "POST",
headers: { headers: authHeaders({
accept: "text/event-stream", accept: "text/event-stream",
"content-type": "application/json", "content-type": "application/json",
}, }),
body: JSON.stringify(body || {}), body: JSON.stringify(body || {}),
signal, signal,
}); });
if (res.status === 401) {
handleUnauthorized(path);
throw new Error("unauthorized");
}
if (!res.ok) { if (!res.ok) {
const text = await res.text().catch(() => ""); const text = await res.text().catch(() => "");
throw new Error(text || `discover_stream_failed:${res.status}`); throw new Error(text || `discover_stream_failed:${res.status}`);