Puppeteer exposes Firefox preferences through extraPrefsFirefox. In an application with a compatible Firefox installation already configured for Puppeteer:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  browser: 'firefox',
  extraPrefsFirefox: {
    'network.proxy.type': 1,
    'network.proxy.http': 'proxy.example',
    'network.proxy.http_port': 8080,
    'network.proxy.ssl': 'proxy.example',
    'network.proxy.ssl_port': 8080,
  },
});
try {
  const page = await browser.newPage();
  await page.goto('https://api.example/');
} finally {
  await browser.close();
}

Type 1 selects manual proxy configuration. Set the hostname and numeric port separately. For permitted public-site navigation, the HTTP proxy list provides candidates for these HTTP listener fields. Firefox uses the ssl preference names for the HTTPS destination route; inventing network.proxy.https names does not configure the same settings.

Specify both routes when both HTTP and HTTPS navigation should use the intermediary. This avoids depending on a settings-dialog action to copy one route into the other. The endpoint shown is a plain HTTP proxy listener; the ssl preference name describes its destination category.

These preferences configure Firefox’s network traffic. Chromium’s --proxy-server argument belongs to another browser interface. Current Puppeteer selects Firefox with browser: 'firefox'; older examples using product should be matched to the Puppeteer version that defined that option.

متعلقہ مضامین