Refused to set unsafe header "user-agent"
See original GitHub issueThis isn’t technically an issue with this library, however it should be noted that neither Chrome nor Safari currently allow setting the “user-agent” header, both throw Refused to set unsafe header "user-agent"
errors.
It might be responsible to detect whether or not the browser allows for setting this header to avoid spurious errors getting thrown.
I’m happy to open a PR if there’s a chance it will go in. We’d certainly like that, as currently we’re getting this error on every page load.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (10 by maintainers)
Top Results From Across the Web
Ajax request: Refused to set unsafe header - Stack Overflow
Therefore I need to post a request to their endpoint with the Referer and the User-Agent properly set. This call should return an...
Read more >Refused to set unsafe header "User-Agent" · Issue #982 - GitHub
Description Every time an api call is made i get the error: Refused to set unsafe header "User-Agent" I'm using the API package...
Read more >Refused to get unsafe header - TrackJS
The message describes a failed attempt to access header data from a network request. We discovered this error while working on a prototype...
Read more >Refused to set unsafe header "User-Agent": connection.js
This toolkit predates the requirement that some headers be rejected if a script tries to set them, and most, if not all, browsers...
Read more >BrowserClient sets unsafe headers causing Chrome to report ...
However on each such send request, Chrome reports an error saying: Refused to set unsafe header "user-agent" Refused to set unsafe header "content-length"....
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 Free
Top 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
Typically we recommend using analytics.js https://segment.com/docs/sources/#website. It has a fair amount of more client side specific features. e.g. grabbing browser context information and loading client side destinations. Another one we’re currently working on is persistent queueing.
There’s definitely nothing wrong with using analytics-node in the browser, it just won’t have the same set of browser specific features as a.js. Depending on your use case, that may be an acceptable trade-off!
I’ve opened an issue with Axios – if they are open to a PR, then a fix upstream will be more useful to everyone.
Leaving the link here and will update as appropriate: https://github.com/axios/axios/issues/1231