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

Lighthouse CLI pass mulitple cookies via --extra-headers #16027

Closed
pascalknupper opened this issue May 31, 2024 · 3 comments
Closed

Lighthouse CLI pass mulitple cookies via --extra-headers #16027

pascalknupper opened this issue May 31, 2024 · 3 comments

Comments

@pascalknupper
Copy link

Question about how to add multiple cookies with different domains

Currently I´m implementing some Lighthouse checks via the CLI tool. Right now I´m facing an issue with adding mulitple cookies to my tests. Adding a single cookie works seamlessly. Adding 2 or more cookies via the CLI seems to be not working.

What is the correct syntax for adding multiple cookies with different domains via Lighthouse CLI?

 lighthouse --extra-headers="{\"Cookie\":\"Cookie1=value1&domain=.foo.com; Cookie2=value2&domain=.bar.com\"}" --chrome-flags="--headless" "https://www.google.de" --only-categories=accessibility,performance
@connorjclark
Copy link
Collaborator

connorjclark commented May 31, 2024

Not sure about CLI, but you may have an easier time using a json file to provide cookies.

lighthouse <url> --extra-headers=./path/to/file.json                                               Path to JSON file of HTTP Header key/value pairs to send in requests

This will let you ignore any escaping needed for your terminal, and just store the values in a plain json object.

@pascalknupper
Copy link
Author

@connorjclark May I ask what would be the syntax of the json object?

{"Cookie":"Cookie1=value1&domain=.foo.com; Cookie2=value2&domain=.bar.com"}

@connorjclark
Copy link
Collaborator

Yes, that is how to set a header value, just a simple json object. The value within the Cookie field is exactly what you'd see in the headers in devtools/curl.

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

No branches or pull requests

5 participants
@brendankenny @connorjclark @devtools-bot @pascalknupper and others