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.
Proxy fields
serveris required. Use an HTTP or SOCKS proxy URL; the shorthost:portform is interpreted as HTTP.usernameandpasswordare optional authentication fields.bypassis 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:
#1 Best Overall
| 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
- Used Book in Good Condition
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.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesAPI 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.
Rank #3
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.requestor 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
usernameandpasswordin 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
bypassfor 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(); inspectresponse.status()and handle the status, or enablefailOnStatusCodeif 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.
Rank #4
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.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →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.
Best Value
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.
Quick Recap
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.




