Issue
Is there a way to configure Puppeteer to use a proxy with Firefox, without manually having to adjust my operating system's proxy settings?
I am able to accomplish this in Chrome by using the command line argument args: [ '--proxy-server=http://0.0.0.0:0000' ]
, but Firefox doesn't seem to have this capability.
Solution
Unfortunately, there is no 'proxy-server' argument in Firefox.
However, you can intercept the request and set a proxy with the puppeteer-proxy library.
Here is an example.
import puppeteer from 'puppeteer';
import { proxyRequest } from 'puppeteer-proxy';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', async (request) => {
await proxyRequest({
page,
proxyUrl: 'http://127.0.0.1:3000',
request,
});
});
await page.goto('http://gajus.com');
})();
It will work in Chrome and Firefox as well.
Answered By - Yevhen Laichenkov Answer Checked By - David Marino (WPSolving Volunteer)