like-gold
like-gold2y 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
like-gold
like-goldOP2y 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?