Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions browse/src/browser-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ export class BrowserManager {
}
}

/**
* Build Playwright proxy config from standard environment variables.
* Prefer explicit HTTP(S) proxy vars; fall back to ALL_PROXY.
*/
private getProxySettings(): { server: string; bypass?: string } | undefined {
const server =
process.env.HTTPS_PROXY ||
process.env.https_proxy ||
process.env.HTTP_PROXY ||
process.env.http_proxy ||
process.env.ALL_PROXY ||
process.env.all_proxy;

if (!server) return undefined;

const bypass = process.env.NO_PROXY || process.env.no_proxy || undefined;
return bypass ? { server, bypass } : { server };
}

async launch() {
// ─── Extension Support ────────────────────────────────────
// BROWSE_EXTENSIONS_DIR points to an unpacked Chrome extension directory.
Expand Down Expand Up @@ -176,6 +195,7 @@ export class BrowserManager {
// browsing user-specified URLs has marginal sandbox benefit.
chromiumSandbox: process.platform !== 'win32',
...(launchArgs.length > 0 ? { args: launchArgs } : {}),
...(this.getProxySettings() ? { proxy: this.getProxySettings() } : {}),
});

// Chromium crash → exit with clear message
Expand Down Expand Up @@ -322,6 +342,7 @@ export class BrowserManager {
viewport: null, // Use browser's default viewport (real window size)
userAgent: this.customUserAgent || customUA,
...(executablePath ? { executablePath } : {}),
...(this.getProxySettings() ? { proxy: this.getProxySettings() } : {}),
// Playwright adds flags that block extension loading
ignoreDefaultArgs: [
'--disable-extensions',
Expand Down Expand Up @@ -988,6 +1009,7 @@ export class BrowserManager {
headless: false,
args: launchArgs,
viewport: null,
...(this.getProxySettings() ? { proxy: this.getProxySettings() } : {}),
ignoreDefaultArgs: [
'--disable-extensions',
'--disable-component-extensions-with-background-pages',
Expand Down