26 lines
565 B
C#
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);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|