Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Configure a Proxy for page.request.get() in Playwright

Set the proxy on the context before calling page.request.get(). Learn when to use a standalone API request context and how to diagnose proxy issues.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the proxy when you create the browser context that owns page.request; page.request.get() does not accept a proxy option. For an API request with separate cookies, create a standalone request context with playwright.request.newContext({ proxy }) instead.

Configure a proxy for page.request.get()

page.request is the APIRequestContext associated with its page’s BrowserContext. Supply the proxy in browser.newContext() before creating the page:

As an Amazon Associate I earn from qualifying purchases.

const browser = await chromium.launch();
const context = await browser.newContext({
  proxy: {
    server: 'http://myproxy.example:3128',
    username: process.env.PROXY_USERNAME,
    password: process.env.PROXY_PASSWORD,
    bypass: 'localhost, .internal.example',
  },
});
const page = await context.newPage();

const response = await page.request.get('https://api.example.com/data');
console.log(response.status());

await context.close();
await browser.close();

Replace the example proxy and target with your own. Keep credentials out of source control; environment variables are used here as a basic way to supply them. The proxy options belong to context creation, not the get() call. The same associated request context is available as page.context().request or browserContext.request. See the Playwright APIRequest reference for proxy fields and the APIRequestContext reference for the request API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Proxy fields

  • server is required. Use an HTTP or SOCKS proxy URL; the short host:port form is interpreted as HTTP.
  • username and password are optional authentication fields.
  • bypass is an optional list of hosts or domains that should not use the proxy. For example, the sample bypasses localhost and hosts under .internal.example.

Choose between associated and standalone API requests

The key decision is whether the API call should share the browser context’s cookies. The associated context and the standalone context differ in cookie storage, setup location, and cleanup:

Request type Where proxy is configured Cookie behavior Lifecycle
page.request or browserContext.request browser.newContext({ proxy }) Shares cookies with the browser context; API responses can update its cookies through Set-Cookie. Close the browser context when finished.
playwright.request.newContext() newContext({ proxy }) Has isolated cookie storage. Call dispose() when finished.

Playwright documents the distinction between context-associated and global request contexts in its API testing guide.

Use an isolated API request context

Choose this when the API request should not share browser cookies, or when you do not need a page at all:

Rank #2
const request = await playwright.request.newContext({
  proxy: {
    server: 'socks5://myproxy.example:1080',
    username: process.env.PROXY_USERNAME,
    password: process.env.PROXY_PASSWORD,
  },
});

try {
  const response = await request.get('https://api.example.com/data');
  console.log(response.status());
} finally {
  await request.dispose();
}

For HTTP and SOCKS schemes, proxy configuration and optional fields are described in the APIRequest reference. The example host is illustrative; substitute a proxy endpoint you are authorized to use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

API proxy traffic is separate from browser page traffic

Configuring the associated API request context is not a substitute for configuring the proxy used by page navigation and browser-originated network requests. If both page.request.get() and the page itself must use a proxy, configure the API request through its context and browser traffic through the browser launch or browser-context proxy setting. Playwright documents browser- and context-level proxy configuration in its HTTP proxy guide.

What to expect from get()

The get() method makes an HTTP(S) GET request and follows redirects automatically. By default, it returns a response for statuses outside the 2xx and 3xx ranges rather than treating every such status as an exception; the failOnStatusCode option can change that behavior. The documented default request timeout is 30,000 milliseconds. Check the APIRequestContext reference for current method options and defaults, particularly if your installed Playwright version differs from the documentation you are consulting.

Troubleshoot proxy requests

  • The request appears not to use the proxy: Confirm whether you are making an API request with page.request or navigating the browser page. Check that the proxy is configured on the relevant context, and verify the scheme, hostname, port, and any bypass entry.
  • The proxy requires authentication: Check that the proxy credentials are supplied as username and password in the proxy configuration and that they are valid. A returned HTTP 407 means proxy authentication is required; distinguish that response from a transport-level connection failure.
  • The request reaches the wrong route: Review bypass for a matching host. A bypassed destination is intentionally excluded from the proxy.
  • The request times out: The documented default is 30 seconds. Verify proxy connectivity and target reachability, then set an appropriate request timeout if the endpoint legitimately needs longer.
  • A non-success status does not throw: This is the normal default for get(); inspect response.status() and handle the status, or enable failOnStatusCode if you want qualifying statuses to fail the call.

These checks follow from the documented configuration fields and response behavior; they are not a guarantee that every proxy failure produces the same status or error. If a setting behaves differently in your project, verify the installed Playwright version against the current references.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup:

If your goal is to capture a webpage rather than make an application API request through a proxy, ScreenshotNeo provides a website screenshot API. One GET request returns a PNG, JPEG, WebP, or PDF; its API is documented at ScreenshotNeo docs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://api.example.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; these steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Learn more at ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Does page.request.get() accept a proxy option?

No. Configure the proxy on the browser context that owns the page, or create a standalone API request context with proxy settings.

Does a proxy set for page.request also proxy page navigation?

Not by itself. Configure browser traffic through the browser or browser-context proxy setting as well when navigation and browser-originated requests must use a proxy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.