I'm trying to set the cookies on each request via Puppeteer request interception. I've noticed that while setting headers['sample-header']=1 creates header 'sample-header' equal to 1, setting headers['cookie'] = x... does not set the requests cookie. For instance, the following code does not set any requests cookies.
const browser = await puppeteer.launch({headless: false,executablePath:dirnae});
const page = await browser.newPage();
const client = await page.target().createCDPSession();
await page.setRequestInterception(true);
page.on('request', request => {
const headers = request.headers();
headers['cookie'] = 1;
request.continue({ headers });
});
page.on('request', request => {
console.log(request.headers())
});
page.on('response', response => {
//console.log(response.headers()['set-cookie'])
});
await page.goto('https://google.com');
EDIT: I figured out that I can see the requests cookie header thru handling of the Network.requestWillBeSentExtraInfo event.
However, I can't seem to edit requests in that event.