{"id":13583046,"url":"https://github.com/gajus/puppeteer-proxy","last_synced_at":"2025-04-04T20:10:19.172Z","repository":{"id":47955457,"uuid":"237040356","full_name":"gajus/puppeteer-proxy","owner":"gajus","description":"Proxies Puppeteer Page requests.","archived":false,"fork":false,"pushed_at":"2024-08-28T07:35:10.000Z","size":49,"stargazers_count":208,"open_issues_count":7,"forks_count":25,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T19:06:08.760Z","etag":null,"topics":["http","proxy","puppeteer"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gajus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-29T17:19:07.000Z","updated_at":"2025-02-27T11:54:09.000Z","dependencies_parsed_at":"2024-10-18T21:13:48.792Z","dependency_job_id":null,"html_url":"https://github.com/gajus/puppeteer-proxy","commit_stats":{"total_commits":52,"total_committers":3,"mean_commits":"17.333333333333332","dds":"0.15384615384615385","last_synced_commit":"5195e5a316ffc8cdd01209c667699e9d994db6df"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fpuppeteer-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fpuppeteer-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fpuppeteer-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fpuppeteer-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gajus","download_url":"https://codeload.github.com/gajus/puppeteer-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242678,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","proxy","puppeteer"],"created_at":"2024-08-01T15:03:13.178Z","updated_at":"2025-04-04T20:10:19.152Z","avatar_url":"https://github.com/gajus.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# puppeteer-proxy 🎎\n\n[![Travis build status](http://img.shields.io/travis/gajus/puppeteer-proxy/master.svg?style=flat-square)](https://travis-ci.org/gajus/puppeteer-proxy)\n[![Coveralls](https://img.shields.io/coveralls/gajus/puppeteer-proxy.svg?style=flat-square)](https://coveralls.io/github/gajus/puppeteer-proxy)\n[![NPM version](http://img.shields.io/npm/v/puppeteer-proxy.svg?style=flat-square)](https://www.npmjs.org/package/puppeteer-proxy)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social\u0026label=Follow)](https://twitter.com/kuizinas)\n\nProxies [Puppeteer](https://github.com/puppeteer/puppeteer) Page requests.\n\n* Allows to change proxy per Page and per Request.\n* Allows to authenticate using http://username:password@proxy schema.\n* Handles cookies.\n* Handles binary files.\n* Supports custom [HTTP(S) agents](https://nodejs.org/api/http.html#http_class_http_agent).\n\n## Motivation\n\nThis package addresses several issues with Puppeteer:\n\n* It allows to set a proxy per Page and per Request ([#678](https://github.com/puppeteer/puppeteer/issues/678))\n* It allows to authenticate against proxy when making HTTPS requests ([#3253](https://github.com/puppeteer/puppeteer/issues/3253))\n\nThe side-benefit of this [implementation](#implementation) is that it allows to route all traffic through Node.js, i.e. you can use externally hosted Chrome instance (such as [Browserless.io](https://www.browserless.io/)) to render DOM \u0026 evaluate JavaScript, and route all HTTP traffic through your Node.js instance.\n\nThe downside of this implementation is that it will introduce additional latency, i.e. requests will take longer to execute as request/ response will need to be always exchanged between Puppeteer and Node.js.\n\n## Implementation\n\npuppeteer-proxy intercepts requests after it receives the request metadata from Puppeteer. puppeteer-proxy uses Node.js to make the HTTP requests. The response is then returned to the browser. When using puppeteer-proxy, browser never makes outbound HTTP requests.\n\n## Setup\n\nYou must call [`page.setRequestInterception(true)`](https://pptr.dev/#?product=Puppeteer\u0026version=v2.1.0\u0026show=api-pagesetrequestinterceptionvalue) before using `pageProxy.proxyRequest`.\n\n## API\n\n```js\nimport {\n  Agent as HttpAgent,\n} from 'http';\nimport {\n  Agent as HttpsAgent,\n} from 'https';\nimport type {\n  Page,\n  Request,\n} from 'puppeteer';\nimport {\n  proxyRequest,\n} from 'puppeteer-proxy';\n\n/**\n * @property agent HTTP(s) agent to use when making the request.\n * @property page Instance of Puppeteer Page.\n * @property proxyUrl HTTP proxy URL. A different proxy can be set for each request.\n * @property request Instance of Puppeteer Request.\n */\ntype ProxyRequestConfigurationType = {|\n  +agent?: HttpAgent | HttpsAgent,\n  +page: Page,\n  +proxyUrl?: string | { http: string, https: string },\n  +request: Request,\n|};\n\nproxyRequest(configuration: ProxyRequestConfigurationType): PageProxyType;\n\n```\n\n## Usage\n\n### Making a GET request using proxy\n\n```js\nimport puppeteer from 'puppeteer';\nimport {\n  proxyRequest,\n} from 'puppeteer-proxy';\n\n(async () =\u003e {\n  const browser = await puppeteer.launch();\n  const page = await browser.newPage();\n\n  await page.setRequestInterception(true);\n\n  page.on('request', async (request) =\u003e {\n    await proxyRequest({\n      page,\n      proxyUrl: 'http://127.0.0.1:3000',\n      request,\n    });\n  });\n\n  await page.goto('http://gajus.com');\n})();\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fpuppeteer-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgajus%2Fpuppeteer-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fpuppeteer-proxy/lists"}