sincecutoff.com
← all changes

k6 browser context proxy option

Introduced 2026-06-30 · score 0.97

HOW TO USE IT

When a k6 browser script needs to route a context’s traffic through a proxy, pass `proxy` to `browser.newContext` and provide `proxy.server`.

import { browser } from 'k6/browser'; export const options = { scenarios: { browser: { executor: 'shared-iterations', options: { browser: { type: 'chromium' } }, }, }, }; export default async function () { const context = await browser.newContext({ proxy: { server: 'http://proxy.test:8080', bypass: 'localhost,127.0.0.1', }, }); const page = await context.newPage(); try { await page.goto('https://test.k6.io/'); } finally { await page.close(); } }

WHY THIS HELPS

Route a browser context's traffic through a proxy while running a k6 browser script.

BEFORE THIS CHANGE

The v2.1.0 release note says environment proxy variables affected only k6’s DevTools WebSocket connection; routing context traffic required a custom-built binary or another approach.

REQUIREMENTS AND LIMITATIONS

  • Version: v2.1.0
  • options.proxy: Proxy settings for all pages in the context; when set, `server` is required.
  • options.proxy.server (required): Proxy server URL, including scheme and port.
  • options.proxy.bypass: Comma-separated hosts to connect to directly, bypassing the proxy.
  • Prerequisite: The documented example configures the browser scenario with `type: 'chromium'`.
  • `proxy.server` must be provided.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card