You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CDP endpoint: /json returns [] before any target exists, and browser-level WS rejects Origin header - breaks DrissionPage #3935
Title: CDP endpoint: /json returns [] before any target exists, and browser-level WebSocket rejects connections with an Origin header — breaks DrissionPage (and other clients that send Origin)
Version:1.1.0-nightly.10512+0d3b3659f (macOS arm64, via Homebrew)
Summary
Two CDP-compat issues make Python clients other than Playwright fail to connect to lightpanda serve:
GET /json returns [] until a target has been created via raw CDP, so clients that probe /json for a type: page entry (e.g. DrissionPage's test_connect) conclude there is no browser on the port — even after Target.createTarget succeeds over WS, /json still lists nothing.
The browser-level WebSocket endpoint (ws://127.0.0.1:9222/) rejects any handshake carrying an Origin header with HTTP 403 Origin not allowed. websocket-client sends Origin by default, so it fails unless suppress_origin=True is passed.
Repro
lightpanda serve --host 127.0.0.1 --port 9222
# 1) /json is empty, unlike Chromium which lists at least one page target
curl -s http://127.0.0.1:9222/json
# -> []# 2) WS handshake with default Origin header is rejected
python3 - <<'EOF'import websocket, jsonws = websocket.create_connection("ws://127.0.0.1:9222/", timeout=10) # sends Originws.send(json.dumps({"id": 1, "method": "Target.createTarget", "params": {"url": "about:blank"}}))print(ws.recv())EOF# -> WebSocketBadStatusException: Handshake status 403 ... Origin not allowed# Works only with suppress_origin=True:
websocket.create_connection("ws://127.0.0.1:9222/", timeout=10, suppress_origin=True)
# 3) Even after createTarget succeeds, /json is still empty
curl -s http://127.0.0.1:9222/json # -> []
Impact
DrissionPage (popular in the Chinese automation ecosystem) fails outright with BrowserConnectError: its connect_browser() polls /json for a type: page tab before attaching. Playwright works fine (it creates targets itself), but the promise of "existing CDP scripts just work" breaks for DrissionPage users.
Any WS client that sends an Origin header (websocket-client default, some browsers tools) gets a 403.
Expected
/json should list existing page targets (like Chromium does), or at least after Target.createTarget.
Browser-level WS endpoint should either accept same-host Origin values (e.g. http://127.0.0.1:<port>) or document the allowlist mechanism. Chromium's behavior: accepts connections regardless of Origin on the DevTools port.
Notes
Benchmark + markdown dump (lightpanda fetch --dump markdown) work great — this is only about first-connection compatibility.
I looked a bit into the DrissionPage implementation, and the fundamental change for us is supporting multiple connections per browser, and that isn't something we currently support. The issue is more than just an accurate target list at /json (or /json/list). I'm not sure when we'll be able to get to this.
Activity
karlseguin commentedon Oct 15, 2026
I looked a bit into the DrissionPage implementation, and the fundamental change for us is supporting multiple connections per browser, and that isn't something we currently support. The issue is more than just an accurate target list at
/json(or/json/list). I'm not sure when we'll be able to get to this.cdp: add --remote-allow-origins flag