Overview

Browserbase offers a flexible proxy system, enabling you to control how your automation traffic is routed across the internet. Whether you need anonymity, geolocation control, or improved reliability, Browserbase makes it easy to integrate proxies into your workflows.

Proxy Configuration Options

With Browserbase, you can:

  • Use built-in proxies: Effortlessly route traffic through our managed residential proxies.

  • Bring your own proxies: Use custom HTTP/HTTPS proxies for greater control over network routing.

  • Combine multiple proxies: Set custom routing rules to direct traffic through different proxies based on domain or location.

Proxies are configured when creating a session through the API or SDK.

Use built-in proxies

Use Browserbase’s built-in proxies to route traffic through managed, residential proxies. This is the simplest option and requires very little setup.

import { Browserbase } from "@browserbasehq/sdk";

const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY! });

async function createSessionWithProxies() {
  const session = await bb.sessions.create({
    projectId: process.env.BROWSERBASE_PROJECT_ID!,
    proxies: true,
  });
return session;
}
const session = await createSessionWithProxies();
console.log("Session URL: https://browserbase.com/sessions/" + session.id);

Set Proxy Geolocation

Set the geolocation of the proxy to a specific country, state, and city. This is useful if you need to proxy traffic to a specific location. If there is no proxy in the specified location, the closest proxy will be used.

import { Browserbase } from "@browserbasehq/sdk";

const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY! });

async function createSessionWithGeoLocation() {
  const session = await bb.sessions.create({
  projectId: process.env.BROWSERBASE_PROJECT_ID!,
  proxies: [
    {
      "type": "browserbase",
      "geolocation": {
        "city": "New York",
        "state": "NY",
        "country": "US"
      }
    }
  ],
  });
return session;
}
const session = await createSessionWithGeoLocation();
console.log("Session URL: https://browserbase.com/sessions/" + session.id);

Custom Proxies

Browserbase supports custom proxy configurations, allowing you to route traffic through your own HTTP or HTTPS proxies. This is useful if you need to enforce specific network routing rules, comply with security policies, or optimize performance with a preferred proxy provider.

To configure a custom proxy, provide the proxy server URL and authentication details when creating a session.

Browserbase validates proxy connections at session creation time. If we are unable to connect to the specified proxy, an error will be thrown. Ensure that your proxy server is accessible and the provided credentials are correct before creating a session.

import { Browserbase } from "@browserbasehq/sdk";

const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY! });

async function createSessionWithCustomProxies() {
  const session = await bb.sessions.create({
    projectId: process.env.BROWSERBASE_PROJECT_ID!,
    proxies: [
      {
        "type": "external",
        "server": "http://...",
        "username": "user",
        "password": "pass",
      }
    ]
  });
  return session;
}

const session = await createSessionWithCustomProxies();
console.log("Session URL: https://browserbase.com/sessions/" + session.id);

Proxies Routing Rules

Combine multiple proxies and define routing rules based on domain patterns. This is particularly useful when different websites require different proxies, such as routing government-related sites through one proxy while using another for general browsing.

Proxies are applied in the order they are listed, meaning the first matching rule is used for each request. If no rule matches a domain pattern, you can use the browserbase proxy type to fall back to Browserbase’s default proxies.

import { Browserbase } from "@browserbasehq/sdk";

const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY! });

async function createSessionWithRouting() {
const session = await bb.sessions.create({
  projectId: process.env.BROWSERBASE_PROJECT_ID!,
  proxies: [
    // Use an external proxy for wikipedia.org
    {
      "type": "external",
      "server": "http://...",
      "username": "user",
      "password": "pass",
      "domainPattern": "wikipedia\.org"
    },
    // Use an external proxy for all other .gov domains
    {
      "type": "external",
      "server": "http://...",
      "username": "user",
      "password": "pass",
      "domainPattern": ".*\.gov"
    },
    // Use the Browserbase proxies for all other domains
    // Excluding this line will not use a proxy on any other domains
    {
      "type": "browserbase"
    }
  ]
  });
return session;
}
const session = createSessionWithRouting()
console.log("Session URL: https://browserbase.com/sessions/" + session.id)

How is proxy usage measured?

Proxy usage is measured by the total amount of data transferred through the proxy. This includes:

  • Webpage content, downloads, and media files

  • HTTP headers, authentication data, and encryption overhead

  • Any requests and responses routed through the proxy

Since all traffic must pass through the proxy server before reaching its final destination, every interaction contributes to your total bandwidth usage.

To reduce proxy usage, refer to our Cost Optimization section.

Limitations

Certain high-risk categories are restricted by our proxy providers and cannot be accessed through proxies, including:

  • All Apple domains, including iTunes and App stores

  • Entertainment (e.g., Netflix, Playstation)

  • Banking and other financial institutions

  • Some Google domains

  • Streaming

  • Ticketing

  • Mailing

Was this page helpful?