Skip to content

Fix ProxyServer default to allow browser context proxy inheritance#3073

Merged
kblok merged 6 commits intomasterfrom
copilot/fix-default-proxy-in-browser-context
Jan 5, 2026
Merged

Fix ProxyServer default to allow browser context proxy inheritance#3073
kblok merged 6 commits intomasterfrom
copilot/fix-default-proxy-in-browser-context

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Browser contexts created with default options were explicitly setting ProxyServer to empty string, overriding the browser's proxy configuration (including OS proxy settings). Pages created directly via IBrowser.NewPageAsync would respect proxy settings, but pages in default browser contexts would not.

Changes

lib/PuppeteerSharp/Cdp/CdpBrowser.cs

  • Removed ?? string.Empty default for ProxyServer parameter in CreateBrowserContextAsync
  • When null, the property is now omitted from CDP message (via JsonIgnoreCondition.WhenWritingNull), allowing proxy inheritance
// Before: Explicitly overrides proxy to empty
ProxyServer = options?.ProxyServer ?? string.Empty,

// After: Allows browser proxy inheritance when unspecified
ProxyServer = options?.ProxyServer,

.gitignore

  • Added testKey.pem to excluded test certificate files

Behavior

  • Default context: CreateBrowserContextAsync() → inherits browser/OS proxy
  • Explicit proxy: CreateBrowserContextAsync(new() { ProxyServer = "..." }) → uses specified proxy (unchanged)
  • Explicit null: CreateBrowserContextAsync(new() { ProxyServer = null }) → inherits browser/OS proxy

Aligns with upstream Puppeteer TypeScript implementation which passes proxyServer without defaulting.

Original prompt

This section details on the original issue you should resolve

<issue_title>Default options of BrowserContextOptions doesn't inherit the browser's ProxyServer</issue_title>
<issue_description>Pages created from IBrowser.NewPageAsync will pick up the OS' proxy server.

Using a browser context created with default options, pages created with IBrowser.NewPageAsync won't pick up the proxy server from the OS.

This was tested with Chrome on Windows.

I suspect that defaulting the BrowserContextOptions.ProxyServer to string.Empty would cause the proxy value to be overridden.</issue_description>

<agent_instructions>CreateBrowserContextAsync should default to null not to string empty</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Custom agent used: Bidi migration
Implement bidi code


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…itance

Co-authored-by: kblok <2198466+kblok@users.noreply.github.com>
@kblok kblok changed the title [WIP] Fix default options of BrowserContextOptions to inherit proxy server Fix default options of BrowserContextOptions to inherit proxy server Jan 5, 2026
Copilot AI and others added 2 commits January 5, 2026 13:19
Co-authored-by: kblok <2198466+kblok@users.noreply.github.com>
@kblok kblok marked this pull request as ready for review January 5, 2026 13:20
Copilot AI review requested due to automatic review settings January 5, 2026 13:20
Copilot AI changed the title Fix default options of BrowserContextOptions to inherit proxy server Fix ProxyServer default to allow browser context proxy inheritance Jan 5, 2026
Copilot AI requested a review from kblok January 5, 2026 13:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Default options of BrowserContextOptions doesn't inherit the browser's ProxyServer

3 participants