Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: a request that finds the login ended reloads the page to the login

The gateway answered every non-page request without a session with a login
redirect, which fetch and EventSource cannot follow across origins, so polls,
forms and streams failed with errors that said nothing about the session. It
now answers anything that does not ask for text/html with a 401 and a
WWW-Authenticate header, and the swarm UI reloads on that 401, from a wrapped
fetch (one place for every call) and from a probe after a stream dies. A second
reload within ten seconds is skipped so a page that keeps answering 401 cannot
loop. The proxy test and the docs follow.
This commit is contained in:
iris 2026-10-28 18:14:58 +01:00 • committed by mara
commit 4d5a65a185

View file

@ -15,6 +15,7 @@ import {
connectionAfterError,
type ConnectionState,
} from "../../ui/stream/connection.js";
import { probeSession } from "../../ui/session/session.js";
export type { ConnectionState };
@ -70,7 +71,12 @@ export function useMessageStream(sinceMinutes: number): {
pending.push(m);
if (frame === null) frame = requestAnimationFrame(flush);
};
es.onerror = () => setConnection(connectionAfterError(es.readyState));
es.onerror = () => {
const state = connectionAfterError(es.readyState);
setConnection(state);
// The browser gave up: say whether the session ended, which `EventSource` does not tell.
if (state === "closed") probeSession();
};
return () => {
drop();
es.close();