Skip to content

Commit

Permalink
Fixed bug with extra_headers when using proxy. (#8)
Browse files Browse the repository at this point in the history
* Bump node-fetch from 2.6.0 to 2.6.1

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <[email protected]>

* Fixed bug with extra_headers when using proxy.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
Yatskov and dependabot[bot] authored Oct 9, 2020
1 parent c8a7e9f commit 20c1ecd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
14 changes: 9 additions & 5 deletions helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,20 @@ exports.perfomAction = async function perfomAction(request, action) {
let page = await exports.getBrowserPage(request.app.get('browser'), request.query.contextId, request.query.pageId);
return lock.acquire(await page._target._targetId, async () => {

let extra_headers = {};

if ('body' in request && 'headers' in request.body) {
await page.setExtraHTTPHeaders(request.body.headers);
extra_headers = { ...request.body.headers };
}

if ('body' in request && 'proxy' in request.body) {
await page.setExtraHTTPHeaders({
'puppeteer-service-proxy-url': request.body.proxy
});
extra_headers['puppeteer-service-proxy-url'] = request.body.proxy
}

if (Object.keys(extra_headers).length !== 0) {
await page.setExtraHTTPHeaders(extra_headers);
}

return action(page, request);
return await action(page, request);
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"debug": "~2.6.9",
"express": "~4.16.1",
"morgan": "~1.9.1",
"node-fetch": "^2.6.0",
"node-fetch": "^2.6.1",
"npm-run-all": "^4.1.5",
"proxy-agent": "^3.1.1",
"puppeteer": "^1.19.0"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,10 @@ nice-try@^1.0.4:
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

node-fetch@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
node-fetch@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==

normalize-package-data@^2.3.2:
version "2.5.0"
Expand Down

0 comments on commit 20c1ecd

Please sign in to comment.