I have a SignalR JavaScript client (https://domainA.com) talking to a SignalR Api (https://domainB.com). Signalr version 2.2.0. I need to pass in a token via a cookie to the Api. While this works in dev it doesn’t work when deployed to an Azure App Service. The cookie is not being sent along with the requests.
JavaScript Code
//Set cookie
document.cookie = "DomainAToken=" + token + "; domain=domainA.com; path=/";
//call signalr hub
$.connection.hub.start({
withCredentials: true
}).done(init);
I am setting the CORS policy on the Api. Owin Startup:
var policy = new CorsPolicy
{
AllowAnyHeader = true,
AllowAnyMethod = true,
SupportsCredentials = true
};
policy.Origins.Add("https://domainA.com");
app.Map("/signalr", map =>
{
map.UseCors(new CorsOptions
{
PolicyProvider = new CorsPolicyProvider
{
PolicyResolver = context => Task.FromResult(policy)
}
});
map.RunSignalR(hubConfiguration);
});
Returning the response headers as follows.
Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: https://domainA.com
In localhost it works, but on Azure, the cookie is not set. Is there no way to make cookies work cross domain with signalr?