fix(bikegear): add proxy support to Playwright browser context

BIKEGEAR_PROXY_URL now applies to the browser-mode fetcher too.
The VPS IP is permanently blocked at Cloudflare network level — a residential
proxy is the only remaining solution. Set BIKEGEAR_PROXY_URL=http://user:pass@host:port.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MOHAN 2026-07-29 07:34:32 +05:30
parent 76bd69a92f
commit 19fd7f16ea

View File

@ -69,6 +69,16 @@ async function getBrowserContext() {
const { chromium } = require("playwright"); const { chromium } = require("playwright");
await fs.mkdir(BROWSER_PROFILE_PATH, { recursive: true }); await fs.mkdir(BROWSER_PROFILE_PATH, { recursive: true });
const proxyOpts = {};
if (PROXY_URL) {
const u = new URL(PROXY_URL);
proxyOpts.proxy = {
server: `${u.protocol}//${u.host}`,
...(u.username ? { username: decodeURIComponent(u.username), password: decodeURIComponent(u.password) } : {}),
};
console.log(`[BIKEGEAR] Browser using proxy: ${u.protocol}//${u.host}`);
}
_context = await chromium.launchPersistentContext(BROWSER_PROFILE_PATH, { _context = await chromium.launchPersistentContext(BROWSER_PROFILE_PATH, {
headless: true, headless: true,
args: [ args: [
@ -80,6 +90,7 @@ async function getBrowserContext() {
locale: "en-US", locale: "en-US",
viewport: { width: 1280, height: 800 }, viewport: { width: 1280, height: 800 },
extraHTTPHeaders: { "Accept-Language": "en-US,en;q=0.9" }, extraHTTPHeaders: { "Accept-Language": "en-US,en;q=0.9" },
...proxyOpts,
}); });
// Apply stealth patches to every new page opened in this context // Apply stealth patches to every new page opened in this context