fix: apply proxy config only if proxy server available
This commit is contained in:
@@ -104,17 +104,20 @@ export class RemoteBrowser {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.context = await this.browser.newContext(
|
const contextOptions: any = {
|
||||||
{
|
viewport: { height: 400, width: 900 },
|
||||||
viewport: { height: 400, width: 900 },
|
// recordVideo: { dir: 'videos/' }
|
||||||
// recordVideo: { dir: 'videos/' }
|
};
|
||||||
proxy: {
|
|
||||||
server: proxyOptions.server,
|
if (proxyOptions.server) {
|
||||||
username: proxyOptions.username ? proxyOptions.username : undefined,
|
contextOptions.proxy = {
|
||||||
password: proxyOptions.password ? proxyOptions.password : undefined,
|
server: proxyOptions.server,
|
||||||
}
|
username: proxyOptions.username ? proxyOptions.username : undefined,
|
||||||
}
|
password: proxyOptions.password ? proxyOptions.password : undefined,
|
||||||
);
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.context = await this.browser.newContext(contextOptions);
|
||||||
this.currentPage = await this.context.newPage();
|
this.currentPage = await this.context.newPage();
|
||||||
const blocker = await PlaywrightBlocker.fromPrebuiltAdsAndTracking(fetch);
|
const blocker = await PlaywrightBlocker.fromPrebuiltAdsAndTracking(fetch);
|
||||||
await blocker.enableBlockingInPage(this.currentPage);
|
await blocker.enableBlockingInPage(this.currentPage);
|
||||||
|
|||||||
Reference in New Issue
Block a user