DVLP / signalr-no-jquery

120 stars 78 forks source link

Cors always disabled #4

Closed tiagogm closed 5 years ago

tiagogm commented 7 years ago

Hello!

I'm been setting up signalr for a project of mine and ran into your project, which ideal for me since I don't want jquery.

I've noticed however in your shim you have setup cors to be false https://github.com/DVLP/signalr-no-jquery/blob/master/src/jQueryShim.js#L90

That means $.support.cors is always be false and cause the connection to use jsonp https://github.com/DVLP/signalr-no-jquery/blob/master/src/signalR.js#L542

I've looked at the code and there doesn't seem to be a way to change it or pass it as option. Is there a way you could expose this an option?

I could submit a PR if you wish.

Cheers!

DVLP commented 7 years ago

Hi thanks for contributing. This is copied from react-native-signalr and it looks like it's hardcoded to false. It looks like originally in jQuery CORS support is automatically detected based on access-control-allow-origin header. This detection mechanism could be just copied in from original jQuery I guess http://stackoverflow.com/questions/15254777/what-is-the-impact-of-having-support-cors-true-on-non-cross-browser-ajax-ca

tiagogm commented 7 years ago

Hey @DVLP

Ah, I see, I couldn't found the jquery detection based on the header you mentioned, I did find this on the code though.

https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js#L26

I could submit a PR with this included on the shim.

narthollis commented 7 years ago

Would it be possible to get a new release with this changed merged in?

It would be highly useful for us in our development environment (and potentially production going forward).