Refused to set '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
- Reactions:12
- Comments:11 (6 by maintainers)
Top Results From Across the Web
how to resolve Refused to set unsafe header "User-Agent" in ...
I can run similar code from C# in the browser without any issues, but not in Javascript. Is there anyway around this. ......
Read more >Refused to set unsafe header "User-Agent" Error with Dall-E ...
Trying the Dall-E api, give the Refused to set unsafe header “User-Agent” Error. Why would Open AI set this so strict, to only...
Read more >Refused to set an unsafe header "User-Agent" - Trailhead
Hi,. When im clicking on checkbox in Vf page the following error is occured. what s the meaning of this error Refused to...
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 >Browser Error: "Refused to set unsafe header 'User Agent'"
I'm not sure it's related, but I noticed this on twitter: .@salesforce users please update your Google Chrome to 31.0.1650.57.
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
In Chrome for example the annoying issue of logging the errors
Refused to set unsafe header "user-agent"
andRefused to set unsafe header "Accept-Encoding"
still persists. Both headers are present in the list of automatically set headers butxhr.js
adapter is not filtering them out.I think the block in
xhr.js
handling this should look like this:Is there any reason against solving it like this which should be considered?
I have ran into this exact issue as well (not using Axios directly, but something else in an Application is). A fix like above does infact make it go away, but that’s only temporarily + locally (aside from writing scripts to update this after “install” 😄)
If it’s as simple as getting a PR in to fix this, I’d be more than happy to help! (Unless there’s a good reason we can’t do this?)