diff --git a/Program.cs b/Program.cs index 768e20b..a6e829c 100644 --- a/Program.cs +++ b/Program.cs @@ -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();