Refused to set unsafe header "User-Agent"
See original GitHub issuesample code
const api = new WooCommerceRestApi({
url: "http://my-personal-store.com",
consumerKey: "ck_xxxxxxxxxx",
consumerSecret: "cs_xxxxxxxx",
version: "wc/v3"
});
const { data : categories } = await api.get(`products/categories`)
fires successfully and return the response but it also spit errors in Chrome console
Refused to set unsafe header “User-Agent”
It is also taking a lot of time to fetch (2-3s) due to throwing and catching (i guess)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:20 (2 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
The XMLHttpRequest#setRequestHeader specifically states that User-Agent must not be set by a client script, and any attempt to set that ...
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

I simply fixed it by adding an empty header object to axiosConifg.
axiosConfig: { headers: {} },seems to do the trick for now.