SignalR icon indicating copy to clipboard operation
SignalR copied to clipboard

Refused to set unsafe header "User-Agent"

Open Marcelh1983 opened this issue 9 years ago • 5 comments

Related to check-in #759. When connection to my signalR hub I get the following error: HttpClient.js:20 Refused to set unsafe header "User-Agent"

Which eventually results in my code in: signalr connection error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.

Marcelh1983 avatar Aug 28 '17 12:08 Marcelh1983

Hello, is your signalr-client.js error in IE?

leehavin avatar Aug 28 '17 12:08 leehavin

No, tested in chrome on windows and mac. I removed pollXhr.setRequestHeader('User-Agent', UserAgent); in Transports and xhr.setRequestHeader('User-Agent', UserAgent); in HttpClient and it works.

Marcelh1983 avatar Aug 28 '17 13:08 Marcelh1983

I tested it on ie, citing signalr client.js error, which is correct in chrome. It has something to do with the syntax of javascript. Why not just launch the native js instead of the ts version? Currently, it appears that only client js does not support IE

leehavin avatar Aug 28 '17 15:08 leehavin

@Marcelh1983 - thanks for reporting. Will look into this. @leehavin - I am working on a IE compatible version. See https://github.com/aspnet/SignalR/pull/772#issuecomment-325066554

moozzyk avatar Aug 28 '17 16:08 moozzyk

Fixed in 69072614530585d6008ad53ecb80638e81de13b7

mikaelm12 avatar Aug 28 '17 21:08 mikaelm12