Files
test/CustomResponseHeaderMiddleware.cs
2024-09-03 09:23:03 +07:00

26 lines
565 B
C#

namespace ngaoda
{
public class CustomResponseHeaderMiddleware
{
private readonly RequestDelegate _next;
public CustomResponseHeaderMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
context.Response.OnStarting(() =>
{
context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
return Task.CompletedTask;
});
await _next(context);
}
}
}