I want to pass authentication token(JWT) in puppeteer headers, for the pdf view with headless chrome in my application? We are using react as our front-end UI. And using puppeteer we are able to generate pdf, but the link to pdf we need to authorize using JWT How do we pass the jwt in headers, does puppeteer support Auth token in headers? Please help.


1 Answers

Thomas Dondorf On Best Solutions

To pass additional headers in the request, you can use the function page.setExtraHTTPHeaders.

Quote from the docs linked above:

The extra HTTP headers will be sent with every request the page initiates.


    'Token': '...', 

All following requests will then have the additional header Token with the set value.