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

Custom User-Agent used in browser produces warning in Chrome #60

Closed
johnboxall opened this issue Dec 9, 2021 · 1 comment
Closed

Custom User-Agent used in browser produces warning in Chrome #60

johnboxall opened this issue Dec 9, 2021 · 1 comment

Comments

@johnboxall
Copy link
Contributor

johnboxall commented Dec 9, 2021

1.4.1 began setting the User-Agent header: 53747ac

It sets the header both in Node.js and browser based environments.

Chrome does not support this and will give you a warning:

Refused to set unsafe header "user-agent"

The related Chrome bug is here: https://bugs.chromium.org/p/chromium/issues/detail?id=571722

Much older versions of the fetch spec did not support setting the User-Agent, but it appears to have been added in ~2015: whatwg/fetch#37. Safari and Firefox both seem to support this behaviour.


I don't think this issue is important to resolve, but wanted to leave my notes here for others potentially encountering it!

@wjhsf
Copy link
Contributor

wjhsf commented Dec 9, 2021

Thanks for documenting this issue! There's not a whole lot we can do about it, as it's a limitation on the browser itself.

As a bit of bonus information, the warning actually comes from cross-fetch. Using Chrome's native fetch results in the custom user agent being silently ignored.

@wjhsf wjhsf closed this as completed Dec 9, 2021
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

2 participants