Skip to content

fix(docker): let dashboard/playground load when auth gate is active#2039

Open
ntohidi wants to merge 1 commit into
developfrom
fix/docker-ui-auth-gate
Open

fix(docker): let dashboard/playground load when auth gate is active#2039
ntohidi wants to merge 1 commit into
developfrom
fix/docker-ui-auth-gate

Conversation

@ntohidi

@ntohidi ntohidi commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2037 — Docker v0.9.0 dashboard and playground return 401 when CRAWL4AI_API_TOKEN is set because AuthGateMiddleware blocks the static UI pages before any HTML can load.

Root cause: The middleware only accepts Authorization: Bearer headers for HTTP requests. Browsers can't attach custom headers to top-level navigation, creating a catch-22: the HTML can't load to bootstrap the JS that would send auth headers.

Fix:

  • Add public_prefixes to AuthGateMiddleware so /dashboard, /playground, /static serve without credentials (they contain no data, only HTML/CSS/JS)
  • Add a token input bar to both UIs that stores the token in sessionStorage
  • Replace all bare fetch() calls with authFetch() that attaches Authorization: Bearer <token>
  • Append ?token= to the monitor WebSocket URL (the gate already accepts this for WS)

All API/data routes remain fail-closed behind the auth gate.

Test plan

  • curl http://localhost:11235/dashboard returns 200 (HTML) with CRAWL4AI_API_TOKEN set
  • curl http://localhost:11235/playground returns 200 (HTML) with CRAWL4AI_API_TOKEN set
  • curl -X POST http://localhost:11235/crawl returns 401 (API stays gated)
  • curl -H "Authorization: Bearer <token>" -X POST http://localhost:11235/crawl returns 200
  • Without CRAWL4AI_API_TOKEN, server binds loopback only (unchanged behavior)

…2037)

The AuthGateMiddleware blocked UI static pages with 401 because browsers
cannot attach Authorization headers to top-level navigation. The UI shell
serves no data, so it is safe to load without credentials.

- Add public_prefixes to AuthGateMiddleware for prefix-based path bypass
- Register /dashboard, /playground, /static as public prefixes
- Add token input bar to both playground and dashboard UIs
- Replace all bare fetch() calls with authFetch() that attaches Bearer token
- Append ?token= to monitor WebSocket URL (gate already accepts it for WS)

All API/data routes remain fail-closed behind the auth gate.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant