Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a cookie to the request #133

Open
arishoham opened this issue Jul 18, 2023 · 2 comments
Open

Adding a cookie to the request #133

arishoham opened this issue Jul 18, 2023 · 2 comments

Comments

@arishoham
Copy link

I need to add a cookie to the page request when lighthouse runs, I tried using extraHeaders in lighthouserc.json like so, but it seems to have no effect. Is there another way to accomplish this?

{
  "ci": {
    "collect": {
      "settings": {
        "chromeFlags": "--no-sandbox --no-zygote --headless --ignore-certificate-errors --disable-dev-shm-usage --max-wait-for-load=30000",
        "extraHeaders": "{\"Cookie\": \"foo=true\"}",
      }
    }
  }
}
@KaiDoering
Copy link
Contributor

KaiDoering commented Jul 20, 2023

You could also try to use a puppeteer script for this like

/**
 * @param {puppeteer.Browser} browser
 * @param  context
 */
module.exports = async (browser, context) => {
    const page = await browser.newPage();
    await page.setCookie({
        name: 'cookie-test',
        value: 'true',
        domain: 'example.com',
    });
    await page.close();
};

@JackG102
Copy link

JackG102 commented May 3, 2024

I was able to send a cookie value using lighthouserc.json. In a non-prod environment, we check for the presence of a certain cookie and a value to allow access to the website. The code below allowed lighthouse to do the scans. If it had no effect, I also would double check in the Github Actions workflow that the config path to the json file is set up: configPath: .github/workflows/lighthouserc.json under the with: key

{
  "ci": {
    "collect": {
      "settings": {
        "extraHeaders": {
          "COOKIE": "cookie_name=value_of_cookie"
        }
      }
    },
    "assert": {

    },
    "upload": {

    },
    "server": {

    },
    "wizard": {

    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants