Replace 'Add' with 'Append' in CORS header methods
In the AllowCrossOriginMiddleware, the method for adding headers to the response has been adjusted. Instead of the 'Add' method which could lead to potential overwriting, 'Append' method is used to ensure that CORS headers are always updated correctly.
This commit is contained in:
@@ -23,10 +23,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
|
||||
context.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
|
||||
context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
||||
context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Accept, Authorization");
|
||||
context.Response.Headers.Append("Access-Control-Allow-Origin", "*");
|
||||
context.Response.Headers.Append("Access-Control-Allow-Credentials", "true");
|
||||
context.Response.Headers.Append("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
||||
context.Response.Headers.Append("Access-Control-Allow-Headers", "Content-Type, Accept, Authorization");
|
||||
|
||||
if (context.Request.Method == "OPTIONS" && !context.Response.HasStarted)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user