question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refused to set unsafe header "user-agent"

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
f2prateekcommented, Dec 20, 2017

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!

1reaction
aaroncraig10ecommented, Dec 9, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found