Skip to content

Commit

Permalink
fix(src/knifehub.web/program.cs): cors
Browse files Browse the repository at this point in the history
The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time
  • Loading branch information
yiyungent committed Oct 22, 2024
1 parent a55486e commit cf25999
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/KnifeHub.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,15 @@ public static void Main(string[] args)
if (configOptions.AllowAllCors)
{
Log.Information("Cors: AllowAllCors");
builder.Services.AddCors(m => m.AddPolicy("AllowAllCors", a => a.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials()));
// System.InvalidOperationException: The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the CORS policy by listing individual origins if credentials needs to be supported.
builder.Services.AddCors(m =>
m.AddPolicy("AllowAllCors",
a => a
//.AllowAnyOrigin()
.SetIsOriginAllowed(_ => true)
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()));
}
else
{
Expand Down

0 comments on commit cf25999

Please sign in to comment.