Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ALL request headers in Puppeteer

I'm trying to get ALL request headers to properly inspect the request, but it only returns headers like the User-Agent and Origin, while the original request contains a lot more headers.

Is there a way of actually getting all the headers?

For reference, here's the code:

const puppeteer = require('puppeteer');

const browser = await puppeteer.launch({
    headless: false
});

const page = await browser.newPage();
page.on('request', req => {
   console.log(req.headers());
});
await page.goto('https://reddit.com');

Thanks in advance, iLinked

like image 685
iLinked Avatar asked Mar 19 '20 15:03

iLinked


1 Answers

U can use the url https://headers.cloxy.net/request.php to see your headers

await page.goto('https://headers.cloxy.net/request.php');

U can also print to log

  console.log((await page.goto('https://example.org/')).request().headers());
like image 141
Elia Weiss Avatar answered Nov 28 '22 04:11

Elia Weiss