Skip to content

[BUG] GUI dashboard intermittently flips to "offline / cannot connect to proxy" with 401 on /api/* while proxy health is OK #3279

Description

@Arkos123

Client or integration

OpenCodex dashboard

Area

Dashboard

Summary

Right after opening the dashboard it shows "online", but within seconds
it flips back to "offline". Reproduction is not fully stable — sometimes it stays online
for a long time with no issue.

Image Image

I check it with AI (for your reference, may not be correct):

Proxy is healthy (measured)

GET /healthz -> 200 {"status":"ok","service":"opencodex","version":"2.40.0","uptime":3063,"pid":44740,"port":10100}
GET /        -> 200 (GUI served, session meta injected)

What we found

  1. GET / injects a fresh loopback GUI session token into the HTML meta
    (opencodex-session-token, -csrf, -origin, -server-origin). Server-side this is
    issueGuiSession() with LOOPBACK_GUI_SESSION_TTL_MS = 5 * 60_000 (gui-session.ts).
  2. The freshly minted token works:

curl -H "Authorization: Bearer $TOKEN"
-H "x-opencodex-gui-origin: http://localhost:10100"
http://localhost:10100/api/system/health
-> 200 {"status":"ok",...}

 But the same token without x-opencodex-gui-origin returns:

 401 {"error":"opencodex admin token required"} (management-auth.ts).
  1. The GUI frontend only installs its window.fetch wrapper (which attaches the session
    token) when Ib() validates that the meta browser origin === window.location.origin
    AND meta server origin === target.serverOrigin; otherwise it clears the session
    (a.session = Ab()), and every subsequent /api/* request goes out without a token
    -> 401 -> dashboard shows offline.

  2. Reproduction of the host mismatch:

  3. After a 401 the frontend tries to re-mint via GET /opencodex-session (Xb/Qb),
    and on failure sets promptCancelled permanently, so the dashboard stays offline until
    the page is reloaded. This explains the flakiness: whether the retry wins or not depends
    on timing/which host the request went out on.

Expected

  • Loopback GUI auth should not depend on the browser host spelling being identical to the
    one at mint time (localhost / 127.0.0.1 / ::1 are all loopback), or
  • The 401 -> re-mint path should converge and never leave the dashboard stuck offline, and
  • A single page load should never require a manual ocx start when the proxy is healthy.

Reproduction

  1. Start ocx and open the dashboard, wait for a few seconds.
  2. The dashboard turns from "online" to "offline"
    (Reproduction is not fully stable. Sometimes it stays online for a long time with no issue.)

Version

2.40.0

Operating system

Windows 10

Provider and model

No response

Logs or error output

Screenshots and supporting files

No response

Redacted configuration

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingguiDashboard, tray, settings UIneeds-infoWaiting on reporter for a concrete spec or reproduction

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions