diff --git a/StudioManager.API/Program.cs b/StudioManager.API/Program.cs index 79afaf7..7d8acaa 100644 --- a/StudioManager.API/Program.cs +++ b/StudioManager.API/Program.cs @@ -8,6 +8,16 @@ var builder = WebApplication.CreateBuilder(args); +builder.Services.AddCors(option => +{ + option.AddPolicy("CorsPolicy", policy => + { + policy.AllowAnyHeader() + .AllowAnyMethod() + .SetIsOriginAllowed(_ => true) + .AllowCredentials(); + }); +}); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); @@ -22,29 +32,18 @@ builder.Services.AddExceptionHandler(); builder.Services.AddProblemDetails(); -builder.Services.AddCors(opt => -{ - opt.AddDefaultPolicy( - policy => - { - policy.AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader(); - }); -}); - var app = builder.Build(); - -app.UseExceptionHandler(); app.UseHttpsRedirection(); -app.UseStaticFiles(); + app.UseRouting(); -app.UseCors(); +app.UseCors("CorsPolicy"); app.UseAuthorization(); app.UseAuthentication(); +app.UseStaticFiles(); +app.UseExceptionHandler(); // Configure the HTTP request pipeline. app.UseSwagger();