Skip to content

feat: Browserbase proxy, stealth, and image blocking via env vars#917

Open
JustYannicc wants to merge 1 commit intovercel-labs:mainfrom
JustYannicc:feat/browserbase-proxy-stealth-config
Open

feat: Browserbase proxy, stealth, and image blocking via env vars#917
JustYannicc wants to merge 1 commit intovercel-labs:mainfrom
JustYannicc:feat/browserbase-proxy-stealth-config

Conversation

@JustYannicc
Copy link

Summary

Adds environment variable support for configuring Browserbase sessions with proxy, advanced stealth, and image blocking. Also includes the fix for #912 (415 error on session creation).

New environment variables:

Variable Description Example
BROWSERBASE_PROXY Enable residential proxy 1
BROWSERBASE_ADVANCED_STEALTH Enable advanced stealth (custom Chromium) 1
BROWSERBASE_OS OS fingerprint for stealth windows, mac, linux, mobile, tablet
BROWSERBASE_BLOCK_IMAGES Block image loading via CDP Fetch interception 1

Implementation:

  • providers.rs: Builds the session creation body from env vars (proxies, browserSettings with advancedStealth/os)
  • actions.rs: After CDP connection, registers abort routes for image extensions and enables Fetch interception when BROWSERBASE_BLOCK_IMAGES=1

Note on image blocking: Per Browserbase docs, blocking images via request interception is not recommended on sites with anti-bot protection, as image/font loading is used to verify legitimate browsers. This is best suited for non-visual automation on sites without such protections.

Test plan

  • Built locally (cargo build --release)
  • Verified 415 fix: -p browserbase creates sessions successfully
  • Verified proxy: BROWSERBASE_PROXY=1 routes through residential IP (confirmed different IP via httpbin.org/ip)
  • Verified image blocking: BROWSERBASE_BLOCK_IMAGES=1 registers Fetch abort routes for image extensions
  • Confirmed image blocking + anti-bot sites conflict (as documented by Browserbase)

Also fixes vercel-labs#912 (415 error on session creation from missing JSON body).

New environment variables for Browserbase provider:
- BROWSERBASE_PROXY=1: enable residential proxy
- BROWSERBASE_ADVANCED_STEALTH=1: enable advanced stealth mode
- BROWSERBASE_OS: set OS fingerprint (windows, mac, linux, mobile, tablet)
- BROWSERBASE_BLOCK_IMAGES=1: block image loading via CDP to save bandwidth

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 18, 2026

@JustYannicc is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines +1122 to +1123
"**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.gif",
"**/*.webp", "**/*.svg", "**/*.ico", "**/*.avif",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.gif",
"**/*.webp", "**/*.svg", "**/*.ico", "**/*.avif",
"*.png", "*.jpg", "*.jpeg", "*.gif",
"*.webp", "*.svg", "*.ico", "*.avif",

Image blocking patterns like **/*.png never match any URL in the route matching logic, so images are intercepted by CDP but then continued instead of aborted, adding latency without blocking anything.

Fix on Vercel

Copy link
Collaborator

@ctate ctate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, @JustYannicc! Clean implementation — the env var approach is consistent and the 415 fix is a welcome bug fix.

A few suggestions before merging:

  1. BROWSERBASE_OS validation — Currently any string is accepted and passed to the API. Consider validating against the documented values (windows, mac, linux, mobile, tablet) and returning a clear error for invalid input, rather than letting the API reject it.

  2. Silent Fetch.enable failure — The let _ = on the Fetch.enable CDP call silently swallows errors. If this fails, image blocking won't work but the user won't know. A warning log would help debuggability.

  3. Image blocking patterns — The glob-style patterns (**/*.png) only match by file extension and will miss images served without extensions (e.g., CDN URLs like https://cdn.example.com/img/abc123). Worth noting in docs or comments that this is extension-based filtering only.

Otherwise LGTM — nice docs in the changeset and good call noting the anti-bot caveat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants