Chrome flag --user-agent not being respected
See original GitHub issueBug
Lighthouse CLI doesn’t make requests with the useragent specified using the configuration options, ex --chrome-flags="--user-agent=lighthousebot"
as seen from outbound network traffic.
Steps to reproduce
- Run your network sniffer/inspector tool.
- Run the following command
lighthouse --output json --chrome-flags="--user-agent=lighthousebot" https://pwa.rocks/ > run1.json
- Inspect the
GET
request forhttps://pwa.rocks/
in the tool launched in step 1.
Current behavior?
Useragent value is Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/66.0.3359.30 Mobile Safari/537.36
Additionally, the JSON report shows the useragent as lighthousebot
Expected behavior?
Useragent
request header should have the value lighthousebot
.
Environment Information
- Affected Channels: CLI
- Lighthouse version: 2.9.4
- Node.js version: 3.10.10
- Operating System: Win10, Win Server 2016, macOS High Sierra Version 10.13.4
- Chrome version: Version 66.0.3359.181 (Official Build) (64-bit)
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Set Chrome policies for users or browsers - Google Support
Enrolled browsers to enforce policies when users open Chrome browser on managed Microsoft Windows, Apple Mac, or Linux computers. Signing in is not...
Read more >User-Agent reduction - Chrome Developers
User-Agent (UA) reduction is the effort to minimize the identifying information shared in the User-Agent string which may be used for ...
Read more >Intent to Deprecate and Freeze: The User-Agent string
We want to freeze and unify (but not remove) the User Agent string in HTTP requests ... Google properties) being broken in some...
Read more >Chrome ignores autocomplete="off" - Stack Overflow
A user agent may allow the user to override an element's autofill field name, e.g. to change it from "off" to "on" to...
Read more >306104 - master_preferences not respected in Chrome 30
Chrome will create a new profile in step 3. Could you attach a copy of that profile's preferences file (~/.config/google-chrome/Default/Preferences)? Settings ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Resurrecting this old thread because I think there are perfectly valid reasons to want device emulation (throttling, viewport) with a custom user-agent (getting around bot detection with a whitelisted UA modifier).
This seems to be the primary reason for LH trumping the UA on emulated tests. Would it be fair to say that passing in Chrome flags is an indication that the user knows what they’re doing? Webpage issues from a custom UA feel like an “expected” (or at least manageable) outcome. Chrome flags being ignored feels unexpected, and as far as I can tell doesn’t have any manageable workaround.
Hm, I’m not sure just that caveat has a place at the moment, but if you want to add a “configuring chrome” doc or something that has some FAQs about common flags like
--headless
, this pitfall, our default flags, the full list of available flags, etc, I think that’d be really great!