Skip to Content
Open source editionGuidesConfigure a proxy

Configure a proxy

Lightpanda supports HTTP and HTTPS proxies with basic or bearer authentication. You can configure the proxy when starting the browser.

Configure HTTP proxy

Use the CLI option --http_proxy when starting Lightpanda to configure the proxy. Ensure your proxy address starts with http:// or https://.

Use a local proxy with the fetch command:

./lightpanda fetch --http_proxy http://127.0.0.1:3000 https://lightpanda.io

Or configure the proxy with serve for the CDP server. All outgoing requests will use the proxy.

./lightpanda serve --http_proxy http://127.0.0.1:3000

HTTP proxy with basic auth

You can configure basic auth for the proxy using the username:password@ format in the proxy address. It works for both fetch and serve commands.

./lightpanda fetch --http_proxy 'http://me:my-password@127.0.0.1:3000' https://lightpanda.io

HTTP proxy with bearer auth

Lightpanda supports bearer auth to authenticate with the --proxy_bearer_token. It works for both fetch and serve commands.

This option will add a Proxy-Authorization header all the outgoing requests.

./lightpanda fetch --http_proxy 'http://127.0.0.1:3000' --proxy_bearer_token 'MY-TOKEN' https://lightpanda.io

Configure a proxy from your Puppeteer/Playwright script

Instead of configuring your proxy auth on Lightpanda’s start, you can pass your username and password in flight from your script using request interceptions.

Puppeteer

With Puppeteer, you have to configure the proxy address when starting Lightpanda.

./lightpanda fetch --http_proxy 'http://127.0.0.1:3000'

Then you can call page.authenticate function to inject your authentication from your script.

const page = await context.newPage(); // Set credentials for HTTP Basic Auth await page.authenticate({ username: 'my_username', password: 'my_password', });

You can find the full example in our demo repository.

Playwright

With Playwright, configure the proxy when creating the browser’s context.

const context = await browser.newContext({ baseURL: baseURL, proxy: { server: 'http://127.0.0.1:3000', username: 'my_username', password: 'my_password', }, }); const page = await context.newPage();

You can find the full example in our demo repository.