Proxies in Playwright
The proxy is set at browser launch or per context, and the credentials are separate fields rather than part of the address.
Launching with a proxy
The server field takes only the scheme, host and port. Playwright expects the credentials separately, in username and password: a http://login:password@host string will not work here.
import { chromium } from "playwright";
const browser = await chromium.launch({
proxy: {
server: "http://HOST:823",
username: "LOGIN__cr.de",
password: "PASSWORD",
},
});
const page = await browser.newPage();
await page.goto("https://ipinfo.io/json");
console.log(await page.textContent("body"));
await browser.close();HOST is the gateway address from your access; LOGIN and PASSWORD are your username and password. All three are on the order page and in “My access”.
Several countries in one process
browser.newContext accepts the same proxy object, so one running browser can hold several contexts in different countries — the country lives in the username field, as the __cr suffix on the login.
Contexts are isolated by cookies and storage, so sessions will not bleed into each other. If a context needs a stable address, put a sticky port from 10000–20000 in server, a different one for each.