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