DVLP / signalr-no-jquery

120 stars 78 forks source link

Having problems with CORS #30

Closed Sokal21 closed 7 years ago

Sokal21 commented 7 years ago

I'm triying to start a connection with a server wich is hosted in another domain, but every tieme I tried to start it I get the "No 'Access-Control-Allow-Origin' header is present on the requested resource" error. How can I fix it?

gingters commented 7 years ago

This is not a problem of the client library. Please look at your SignalR server configuration and make sure you provide the correct CORS headers. Please see https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#how-to-establish-a-cross-domain-connection for details.

Sokal21 commented 7 years ago

Yes, It was problem of the server. Thanks for your answer!

2017-10-20 8:59 GMT-03:00 Sebastian P.R. Gingter notifications@github.com:

This is not a problem of the client library. Please look at your SignalR server configuration and make sure you provide the correct CORS headers. Please see https://docs.microsoft.com/en-us/aspnet/signalr/overview/ guide-to-the-api/hubs-api-guide-javascript-client#how- to-establish-a-cross-domain-connection for details.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DVLP/signalr-no-jquery/issues/30#issuecomment-338186485, or mute the thread https://github.com/notifications/unsubscribe-auth/ARyeGKtzdbZUeTZcK7RW2vldIFLDLcTSks5suIscgaJpZM4PHZ0o .

trsh commented 7 years ago

@Sokal21 then close this :P

PeopleDispose commented 5 years ago

Hello,

I'm facing the same issue, but with enabled support of JSONP:

ASP.NET startup sample:

var config = new HttpConfiguration();
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
...
appBuilder.MapSignalR(new HubConfiguration {EnableJSONP = true});

Client code sample:

const connection = hubConnection('http://localhost:5042')
connection.start({ jsonp: true })

I'm using: Microsoft.AspNet.WebApi.Core 5.2.7 Microsoft.AspNet.SignalR.Core 2.4.0 Client is React component.

Can you please tell what I'm doing wrong?