feat: Browserbase proxy, stealth, and image blocking via env vars#917
feat: Browserbase proxy, stealth, and image blocking via env vars#917JustYannicc wants to merge 1 commit intovercel-labs:mainfrom
Conversation
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>
|
@JustYannicc is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
| "**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.gif", | ||
| "**/*.webp", "**/*.svg", "**/*.ico", "**/*.avif", |
There was a problem hiding this comment.
| "**/*.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.
ctate
left a comment
There was a problem hiding this comment.
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:
-
BROWSERBASE_OSvalidation — 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. -
Silent
Fetch.enablefailure — Thelet _ =on theFetch.enableCDP call silently swallows errors. If this fails, image blocking won't work but the user won't know. A warning log would help debuggability. -
Image blocking patterns — The glob-style patterns (
**/*.png) only match by file extension and will miss images served without extensions (e.g., CDN URLs likehttps://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.
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:
BROWSERBASE_PROXY1BROWSERBASE_ADVANCED_STEALTH1BROWSERBASE_OSwindows,mac,linux,mobile,tabletBROWSERBASE_BLOCK_IMAGES1Implementation:
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 whenBROWSERBASE_BLOCK_IMAGES=1Note 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
cargo build --release)-p browserbasecreates sessions successfullyBROWSERBASE_PROXY=1routes through residential IP (confirmed different IP via httpbin.org/ip)BROWSERBASE_BLOCK_IMAGES=1registers Fetch abort routes for image extensions