Cors
This commit is contained in:
+14
@@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.ConfigureKestrel(serverOptions => {});
|
||||
@@ -82,6 +83,19 @@ builder.Services.AddCors(options =>
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
// Enable OPTIONS requests to reach controllers
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
if (context.Request.Method == HttpMethods.Options)
|
||||
{
|
||||
context.Response.StatusCode = 204;
|
||||
return;
|
||||
}
|
||||
|
||||
await next();
|
||||
});
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user