This commit is contained in:
Mikhail Kuznetsov
2023-06-01 16:42:44 +10:00
parent f0d28c0802
commit e465932222
29 changed files with 206 additions and 34 deletions

View File

@@ -0,0 +1,25 @@
using PARR.API.Settings;
namespace PARR.API.Installers
{
public static class CorsInstaller
{
public static void InstallCorsServices(this IServiceCollection services)
{
services.AddCors();
}
public static void InstallCors(this WebApplication app, WebApplicationBuilder builder)
{
var corsSettings = new CorsSettings();
builder.Configuration.GetSection(nameof(CorsSettings)).Bind(corsSettings);
app.UseCors(opt =>
opt.WithOrigins(corsSettings.AllowHostsArray)
.AllowAnyHeader()
.AllowAnyMethod()
);
}
}
}