question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set Host header using `setExtraHTTPHeaders` `net::ERR_INVALID_ARGUMENT`

See original GitHub issue

Steps to reproduce

  • Puppeteer version: 5.0.0

What steps will reproduce the problem?

const puppeteer = require('puppeteer');


(async () => {
  const browser = await puppeteer.launch({
    args: [
        '--no-sandbox',
        '--headless',
        '--disable-gpu',
        '--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0'
    ]
  });
  await new Promise(resolve => setTimeout(resolve, 5000));
  const page = await browser.newPage();
  await page.setExtraHTTPHeaders({'Host': 'bukdjango_captcha.com'})
  await page.goto('http://bukdjango_captcha.com:8000/recaptcha_v3');
  await page.screenshot({path: 'example.png'});

  console.log(await page.content())
    await browser.close();
})();

What is the expected result? I can override host header.

What happens instead?

tests_browser_1      | (node:1) UnhandledPromiseRejectionWarning: Error: net::ERR_INVALID_ARGUMENT at http://bukdjango_captcha.com:8000/recaptcha_v3
tests_browser_1      |     at navigate (/dockertestapp/node_modules/puppeteer/lib/cjs/common/FrameManager.js:96:23)
tests_browser_1      |     at processTicksAndRejections (internal/process/task_queues.js:93:5)
tests_browser_1      |     at async FrameManager.navigateFrame (/dockertestapp/node_modules/puppeteer/lib/cjs/common/FrameManager.js:71:21)
tests_browser_1      |     at async Frame.goto (/dockertestapp/node_modules/puppeteer/lib/cjs/common/FrameManager.js:296:16)
tests_browser_1      |     at async Page.goto (/dockertestapp/node_modules/puppeteer/lib/cjs/common/Page.js:749:16)
tests_browser_1      |     at async /dockertestapp/test.js:16:3
tests_browser_1      |   -- ASYNC --
tests_browser_1      |     at Frame.<anonymous> (/dockertestapp/node_modules/puppeteer/lib/cjs/common/helper.js:109:19)
tests_browser_1      |     at Page.goto (/dockertestapp/node_modules/puppeteer/lib/cjs/common/Page.js:749:53)
tests_browser_1      |     at Page.<anonymous> (/dockertestapp/node_modules/puppeteer/lib/cjs/common/helper.js:110:27)
tests_browser_1      |     at /dockertestapp/test.js:16:14
tests_browser_1      |     at processTicksAndRejections (internal/process/task_queues.js:93:5)
tests_browser_1      | (Use `node --trace-warnings ...` to show where the warning was created)
tests_browser_1      | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise whi
ch was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (r
ejection id: 1)
tests_browser_1      | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exi
t code.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:17

github_iconTop GitHub Comments

2reactions
kaspers1778commented, Oct 14, 2020

Got same problem with chromedp on Golang.Did you find any sollution yet?

2reactions
pxCaptchacommented, Jul 26, 2020

already tried… didnt work

Read more comments on GitHub >

github_iconTop Results From Across the Web

795336 - Can't set Host: headers via Chrome DevTools ...
Issue 795336: Can't set Host: headers via Chrome DevTools "Network.setExtraHTTPHeaders" anymore. Reported by schedule max.m.
Read more >
How do I set multiple custom HTTP headers in puppeteer?
You are able to set multiple HTTP headers with the dedicated puppeteer method: page.setExtraHTTPHeaders as well. E.g.: await page.
Read more >
Host - HTTP - MDN Web Docs
The Host request header specifies the host and port number of the server to which the request is being sent.
Read more >
SetExtraHTTPHeaders - Headless - Google Groups
I am working with Headless Chromium and am attempting to add a cookie to the HTTP request header using network::SetExtraHTTPHeaders.
Read more >
Page.setExtraHTTPHeaders() method - Puppeteer
headers, Record<string, string>, An object containing additional HTTP headers to be sent with every request. All header values must be strings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found