feat: support custom headers for CDP connect#459
Open
giulio-leone wants to merge 1 commit intovercel-labs:mainfrom
Open
feat: support custom headers for CDP connect#459giulio-leone wants to merge 1 commit intovercel-labs:mainfrom
giulio-leone wants to merge 1 commit intovercel-labs:mainfrom
Conversation
- Pass headers from CLI --headers flag through to daemon via AGENT_BROWSER_HEADERS env var - Apply headers post-connection using context.setExtraHTTPHeaders() in connectViaCDP() - Add AGENT_BROWSER_HEADERS env var fallback in flags.rs - Parse AGENT_BROWSER_HEADERS in daemon.ts auto-launch flow Playwright's connectOverCDP() does not support connection-time headers, so headers are applied to browser contexts after the CDP connection is established.
Contributor
|
@g97iulio1609 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #396
Summary
Adds support for custom HTTP headers when connecting to a browser via CDP (Chrome DevTools Protocol).
Changes
src/browser.ts:connectViaCDP()now accepts an optionalheadersparameter and applies them to all browser contexts after connection viacontext.setExtraHTTPHeaders()src/daemon.ts: ParsesAGENT_BROWSER_HEADERSenv var (JSON string) and passes it to the launch commandcli/src/connection.rs:ensure_daemon()accepts aheadersparameter and forwards it asAGENT_BROWSER_HEADERSenv var to the daemon process (both Unix and Windows)cli/src/main.rs: Passesflags.headerstoensure_daemon()cli/src/flags.rs: InitializesheadersfromAGENT_BROWSER_HEADERSenv var as fallback (CLI--headersflag takes precedence)Usage
Note on Playwright limitation
Headers are applied post-connection, not during the WebSocket handshake. Playwright's
connectOverCDP()does not support connection-time headers, so we set them on the browser context immediately after the CDP connection is established usingcontext.setExtraHTTPHeaders(). This means headers will be included in all subsequent HTTP requests made by pages in the connected browser, but not in the initial CDP WebSocket connection itself.