Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(browser): reload viewer after ticket exchange

Rahman7cad6557246e
diff --git a/lib/camoufox/viewer-gate.test.ts b/lib/camoufox/viewer-gate.test.ts
index 5c9086da..862030d2 100644
--- a/lib/camoufox/viewer-gate.test.ts
+++ b/lib/camoufox/viewer-gate.test.ts
@@ -97,6 +97,18 @@ describe("the Camoufox split-origin VNC bridge", () => {
expect(asset.headers.get("cache-control")).toBe("no-store");
});
+ it("forces a network reload after the ticket exchange instead of a hash-only navigation", async () => {
+ const proxy = await load();
+ const response = await proxy(req(VIEWER_HOST, "/__viewer_bootstrap.js"));
+ expect(response.status).toBe(200);
+ const script = await response.text();
+ expect(script).toContain("p.delete('viewer_ticket')");
+ expect(script).toContain("history.replaceState");
+ expect(script).toContain("p.toString()");
+ expect(script).toContain("location.reload()");
+ expect(script).not.toContain("location.replace(");
+ });
+
it("does not accept the cockpit session cookie on the sibling viewer host", async () => {
const proxy = await load();
const page = await proxy(req(
diff --git a/lib/camoufox/viewer-gate.ts b/lib/camoufox/viewer-gate.ts
index a0e54513..d8894a5e 100644
--- a/lib/camoufox/viewer-gate.ts
+++ b/lib/camoufox/viewer-gate.ts
@@ -64,7 +64,8 @@ const BOOTSTRAP_JS = [
"p.delete('viewer_ticket');",
"const r=await fetch('/__viewer_auth',{method:'POST',headers:{authorization:'Bearer '+t},credentials:'include',cache:'no-store'});",
"if(!r.ok){document.body.textContent='Viewer authorization failed.';return;}",
- "location.replace(location.pathname+location.search+(p.toString()?'#'+p.toString():''));",
+ "history.replaceState(null,'',location.pathname+location.search+(p.toString()?'#'+p.toString():''));",
+ "location.reload();",
"})().catch(()=>{document.body.textContent='Viewer authorization failed.';});",
].join("");