Using Proxies with Puppeteer or Playwright


We make it very easy to use your own or third-party proxies with our service.


Simply pass a ?proxy= parameter to configure our browsers with the proxy you specified.

For a simple example (without proxy authentication), see below:


const puppeteer = require('puppeteer')

const browser = await puppeteer.connect({
    browserWSEndpoint: 'wss://chrome.headlesstesting.com?token=[YOUR-TOKEN]&proxy=https://myproxy.local:3333'
})

const page = await browser.newPage()
await page.goto('https://headlesstesting.com')
browser.close()
const pw = require('playwright')

(async () => {
  const browser = await pw.chromium.connect({
    wsEndpoint: 'wss://chrome.headlesstesting.com?token=[YOUR-TOKEN]&proxy=https://myproxy.local:3333',
  })

  const context = await browser.newContext()
  const page = await context.newPage()
  await page.goto('https://headlesstesting.com/')
  await browser.close()
})()

Proxy Authentication

To authenticate against the proxy you supplied, you can use 2 options:


page.setExtraHTTPHeaders

You can authenticate against the proxy by setting a Proxy-Authorization header.
Important: the username and password you supply should be base64 encoded.


await page.setExtraHTTPHeaders({
    'Proxy-Authorization': 'Basic username:password',
    // or you can use:
    Authorization: 'Basic username:password',
})

page.authenticate

This will instruct the browser to enter the username and password you supply in the input dialog requesting authentication.


await page.authenticate({
    username: 'username',
    password: 'password',
})