I'm using the latest version of SignalR from NET6. I have a JavaScript client in MVC 4 calling the hub. When I publish to Azure, I get a CORS error on the negotiation handshake. If I turn off the negotiation the CORS error goes away. Why does the negotiation call not use my CORS policy? What are the pros and cons for the negotiation?
Here's my JavaScript console:
Here's my NET6 API CORS policy:
builder.Services.AddCors(options => options.AddPolicy("CorsPolicy",
builder =>
{
builder.AllowAnyMethod().AllowAnyHeader().WithOrigins
(
//omitted
).AllowCredentials().SetIsOriginAllowed(o => true).WithMethods("GET", "POST");
}));
My client builder:
var connection = new signalR.HubConnectionBuilder()
.withUrl(connectionUrl,
{
accessTokenFactory: () => {
if (typeof bearerToken !== 'undefined') {
return bearerToken.getToken;
}
},
skipNegotiation: true, //if I change this to false the error occurs
transport: signalR.HttpTransportType.WebSockets,
})
.withAutomaticReconnect()
.configureLogging(signalR.LogLevel.Information)
.build();
skipNegotiation: true removes the error