using Microsoft.Extensions.DependencyInjection;

namespace HRD.WebApi.Helpers
{
    public static class CorsExtension
    {
        public static void AddCustomCors(this IServiceCollection services, string policyName)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(policyName,
                    builder =>
                    {
                        builder
                            .AllowCredentials()
                            //.AllowAnyOrigin()
                            .SetIsOriginAllowed(origin => true)
                            .AllowAnyHeader()
                            .AllowAnyMethod();
                    });
            });
        }
    }
}