Skip to content

Commit

Permalink
fix(core): set extraHttpHeaders and cookies on page change
Browse files Browse the repository at this point in the history
Fixes #92 (maybe)
  • Loading branch information
harlan-zw committed May 15, 2023
1 parent ee608b7 commit 7dd92c9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/core/src/puppeteer/tasks/lighthouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,13 @@ export const runLighthouseTask: PuppeteerTask = async (props) => {
if (resolvedConfig.auth)
await page.authenticate(resolvedConfig.auth)

if (resolvedConfig.cookies)
await page.setCookie(...resolvedConfig.cookies)

if (resolvedConfig.extraHeaders)
await page.setExtraHTTPHeaders(resolvedConfig.extraHeaders)

// Wait for Lighthouse to open url, then allow hook to run
browser.on('targetchanged', async (target) => {
const page = await target.page()
if (resolvedConfig.cookies)
await page.setCookie(...resolvedConfig.cookies)
if (resolvedConfig.extraHeaders)
await page.setExtraHTTPHeaders(resolvedConfig.extraHeaders)
if (page)
await hooks.callHook('puppeteer:before-goto', page)
})
Expand Down

0 comments on commit 7dd92c9

Please sign in to comment.