Yaffle / EventSource

a polyfill for http://www.w3.org/TR/eventsource/
MIT License
2.11k stars 338 forks source link

Issue passing Authorization header in old Safari? #171

Closed paolodina closed 3 years ago

paolodina commented 3 years ago

Hi, I'm using the Authorization header with EventSource polyfill. Everything works great with Chrome, Firefox and recent Safari, but with Safari 9 the header is not sent to the server (it's missing from the browser request). I see that only since Safari 10.1 the Fetch API is supported. Could this be the reason? And eventually is there anything I can do to fix/workaround the issue?

If it matters, I create the instance this way:

new EventSourcePolyfill(this.url, {
    withCredentials: this.withCredentials,
    lastEventIdQueryParameterName: 'last-id',
    headers: { Authorization: 'Token the_token' },
});
Yaffle commented 3 years ago

it is using XMLHttpRequest#setRequestHeader, not sure if there are some bugs or it does not allow to set Authorization

paolodina commented 3 years ago

It turned out it was an error in my code! Sorry for bothering, thanks for the polyfill.

Yaffle commented 3 years ago

@paolodina , was it on the server side? Thanks for closing the issue

paolodina commented 3 years ago

@Yaffle Nope, it's client side. I still don't know where exactly the mistake is, but a friend told me that before the last client refactoring (which was big) it stopped working.

Yaffle commented 3 years ago

@paolodina because the client side code looks good