39a5aa91ed
The Electron shell boots by fetching / and extracting window.__HERMES_SESSION_TOKEN__ to authenticate /api/ws (dashboard-token.ts adoptServedDashboardToken). Headless serve 404'd every path, so when the renderer's spawn token drifted from the backend's live token — e.g. hermes update replaced the backend and the env pin no longer matched — the renderer had no way to adopt the served token, the WebSocket handshake failed, and the primary window white-screened (#95575). Serve a minimal token-only HTML page at the exact root path in mount_spa()'s headless branch, matching the renderer's extraction regex. Gate it on app.state.auth_required read at request time: a gated (non-loopback / remote public_url) serve keeps returning the 404 JSON so the session token never leaks past the loopback boundary. Every other path stays 404 JSON — the SPA remains unserved. Regression tests: TestHeadlessServeTokenPage (3 cases) — verified to fail against the pre-fix headless branch.