conscious-sapphire
conscious-sapphire3y ago

How to set cookies and headers before requests are sent

How does one set cookies and headers for every request? I can't see any examples of this being done in the documentation?
1 Reply
conscious-sapphire
conscious-sapphireOP3y ago
This was hard to find...
preNavigationHooks: [
async (crawlingContext, gotoOptions) => {
const { page } = crawlingContext;
await page.context().addCookies(state.cookies);
},
],
preNavigationHooks: [
async (crawlingContext, gotoOptions) => {
const { page } = crawlingContext;
await page.context().addCookies(state.cookies);
},
],
`

Did you find this page helpful?