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.
Problem
When using
playwright-cliwith a remote browser endpoint via config, thecreateRemoteBrowserfunction inbrowserFactory.tsonly passesendpointtoconnectToBrowser:This means
exposeNetwork(and otherConnectOptionslikeheaders,slowMo,timeout) cannot be configured for remote connections. For example, settingexposeNetwork: '<loopback>'is required for the remote browser to accesslocalhoston 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
connectOptionsinplaywright.config.ts.Proposed Solution
Change
remoteEndpointin the config type fromstringtostring | ConnectOptions:Where
ConnectOptionsis the existing type frompackages/playwright-core/src/client/types.ts: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
localhoston the client machine for testing local dev servers.Current Workaround
None — users must use the test runner's
connectOptionsinstead of the CLI.Notes
The CLI daemon (
cli-daemon) and MCP server share the samebrowserFactory.tsandconfig.d.tsunderpackages/playwright-core/src/tools/mcp/, so this fix benefits both entry points.