After updating SignalR my program started to fail with the following error message:
Access to XMLHttpRequest at 'http://localhost:22135/chat/negotiate?jwt=<removed the jwt key>' from origin 'http://localhost:53150' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
To fix it I had to update the CORS policy by adding the AllowCredentials() method:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddCors(options => | |
{ | |
options.AddPolicy("AllowAllOrigins", | |
builder => | |
{ | |
builder | |
.AllowAnyOrigin() | |
.AllowAnyHeader() | |
.AllowAnyMethod() | |
.AllowCredentials(); | |
}); | |
}); |