question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

extraHeaders doesn't work when using chrome started with --headless

See original GitHub issue

I’m using chrome-launcher in node to start a chrome instance with the chrome flag --headless set. I’m then using the npm module version of lighthouse and passing it this chrome instance’s port to use. When setting extraHeaders it will only work if I don’t pass the --headless option to chrome launcher. If I remove it, the headers are sent fine to the server, if I enable it my headers are missing even though the headers show fine in the report.json under runtimeConfig.extraHeaders.

What further confuses me, is if I don’t use the lighthouse npm module, and instead use the cli (bypassing the need for chrome launcher) and I pass the --extra-headers argument it also works fine and sends the headers correctly.

I’m using the current version of lighthouse.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
patrickhulcecommented, Jul 6, 2018

@santoshjoseph99 --extraHeaders is a LH flag, not a chrome flag 😃

It seems like pwmetrics passes the flags straight through to LH, so you should be able to do

const options = {
  flags: {
    extraHeaders: {Cookie: 'monster=blue', 'x-men': 'wolverine'}
  }
}

seems like the original topic of this issue has been resolved though, so I’ll go ahead and close this.

2reactions
zackilescommented, May 3, 2018

@patrickhulce sorry for the confusion.

I’ve confirmed it is not working passing --headless through the CLI like you’ve described. You can close this issue and I’ll follow up with the Chrome team. Thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can the browser turned headless mid-execution when it was ...
Short answer: It's not possible. Chrome only allows to either start the browser in headless or non-headless mode. You have to specify it ......
Read more >
Headless Chrome Web Browser Interface • chromote
It works with Chrome, Chromium, Opera, Vivaldi, and other browsers based on Chromium. By default it uses Google Chrome (which must already be...
Read more >
headless-chrome-crawler - npm
Distributed web crawler powered by Headless Chrome. Latest version: 1.8.0, last published: 4 years ago. Start using headless-chrome-crawler ...
Read more >
An Introduction To Running Lighthouse Programmatically
One of the simplest ways to run Lighthouse is through Chrome's DevTools Lighthouse panel. If you open your site in Chrome and then...
Read more >
Getting Started with Headless Chrome - Chrome Developers
Engineer at Google working on web tooling: Headless Chrome, Puppeteer, Lighthouse ... Since you don't have browser UI to see the page, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found