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:
Anduin Xue
2024-02-19 09:21:02 +00:00
parent d8f39e1bb1
commit 4a70a611e4
@@ -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)
{