-
Notifications
You must be signed in to change notification settings - Fork 78
Cross Domain Hub
Justin Maier edited this page Nov 20, 2015
·
1 revision
#Cross-Domain Hub Example
Part of an owin startup class for a website which hosts a hub that is accessible cross-domain.
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Branch the pipeline here for requests that start with "/signalr"
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
EnableDetailedErrors = true,
EnableJSONP = true,
EnableJavaScriptProxies = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
}
}
Note that in the sample I use map.UseCors(CorsOptions.AllowAll);
which is probably not what you want in a production environment, but is useful for testing.