Skip to content

[Feature] exposeNetwork not supported for remote browser connections in CLI config #40478

@Ek03ansh

Description

@Ek03ansh

Problem

When using playwright-cli with a remote browser endpoint via config, the createRemoteBrowser function in browserFactory.ts only passes endpoint to connectToBrowser:

const browser = await connectToBrowser(playwrightObject, { endpoint });

This means exposeNetwork (and other ConnectOptions like headers, slowMo, timeout) cannot be configured for remote connections. For example, setting exposeNetwork: '<loopback>' is required for the remote browser to access localhost on the client machine (via SOCKS proxy tunneling), but there's no way to pass it through the CLI config.

In contrast, Playwright's test runner correctly supports these options via connectOptions in playwright.config.ts.

Proposed Solution

Change remoteEndpoint in the config type from string to string | ConnectOptions:

remoteEndpoint?: string | ConnectOptions;

Where ConnectOptions is the existing type from packages/playwright-core/src/client/types.ts:

type ConnectOptions = {
  endpoint: string;
  browserName?: string;
  headers?: { [key: string]: string; };
  exposeNetwork?: string;
  slowMo?: number;
  timeout?: number;
};

This allows users to either pass a plain URL string (existing behavior) or a full options object:

{
  "browser": {
    "remoteEndpoint": {
      "endpoint": "wss://...",
      "exposeNetwork": "<loopback>",
      "headers": { "x-custom": "value" }
    }
  }
}

Use Case

Connecting to Azure Playwright Testing (or any remote browser service) while needing the remote browser to access localhost on the client machine for testing local dev servers.

Current Workaround

None — users must use the test runner's connectOptions instead of the CLI.

Notes

The CLI daemon (cli-daemon) and MCP server share the same browserFactory.ts and config.d.ts under packages/playwright-core/src/tools/mcp/, so this fix benefits both entry points.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions