Connect to a different domain

Topics: Developer Forum
Jan 11, 2014 at 5:33 PM
Hi,

I have upload the chat on my server and it's work great on the same domain.
Example:
http://www.firstdomain.com/lcsk/agent.html
http://www.firstdomain.com/chat.html

But if I put chat.html file on another domain
http://www.secondomain.com/chat.html (with the js files point on the first domain)
The chat is always offline. How I can connect the chat in different domains?

It's possible?

Thank you
Coordinator
Jan 30, 2014 at 10:43 AM
In javascript requests should be made to the same domain by default.

You can enable Cross-Domain requests in the SignalR Startup file /LCSK/Startup.cs i.e.

app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
map.RunSignalR(new HubConfiguration { EnableJSONP = true });
});

You might have to add this to your web.config:

<system.webServer>
<httpProtocol>
<customHeaders>
  <add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>

And you might enable it also on the client. Depending on your infrastructure CORS might not be available, SignalR will fail back to JSONP, but you might not enable CORS if it's not available, otherwise SignalR will not use JSONP.

Do a search for SignalR and cross-domain requests that should help.

Good luck,
Dominic