mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 05:30:46 +08:00
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:
parent
a3bdad5be1
commit
325bce0413
1 changed files with 8 additions and 3 deletions
|
|
@ -563,15 +563,20 @@ export async function discoverTopologyNeighborsStream(
|
|||
handlers: TopologyDiscoverStreamHandlers,
|
||||
signal?: AbortSignal,
|
||||
): 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",
|
||||
headers: {
|
||||
headers: authHeaders({
|
||||
accept: "text/event-stream",
|
||||
"content-type": "application/json",
|
||||
},
|
||||
}),
|
||||
body: JSON.stringify(body || {}),
|
||||
signal,
|
||||
});
|
||||
if (res.status === 401) {
|
||||
handleUnauthorized(path);
|
||||
throw new Error("unauthorized");
|
||||
}
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => "");
|
||||
throw new Error(text || `discover_stream_failed:${res.status}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue