Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit bfa0443

Browse files
committed
Aggiunti metodi statici POLICY CORS
1 parent b88e166 commit bfa0443

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/NET6CustomLibrary/Extensions/DependencyInjection.cs

+33
Original file line numberDiff line numberDiff line change
@@ -455,4 +455,37 @@ public static IServiceCollection AddFluentValidationService<TAssembly>(this ISer
455455
return services;
456456
}
457457
#endregion
458+
459+
#region "POLICY CORS"
460+
public static IServiceCollection AddPolicyCors(this IServiceCollection services, string policyName)
461+
{
462+
services.AddCors(options =>
463+
{
464+
options.AddPolicy($"{policyName}", policy =>
465+
{
466+
policy.AllowAnyOrigin()
467+
.AllowAnyHeader()
468+
.AllowAnyMethod();
469+
});
470+
});
471+
472+
return services;
473+
}
474+
475+
public static IServiceCollection AddFullPolicyCors(this IServiceCollection services, string policyName)
476+
{
477+
services.AddCors(options =>
478+
{
479+
options.AddPolicy($"{policyName}", policy =>
480+
{
481+
policy.AllowAnyOrigin()
482+
.AllowAnyHeader()
483+
.AllowAnyMethod()
484+
.AllowCredentials();
485+
});
486+
});
487+
488+
return services;
489+
}
490+
#endregion
458491
}

0 commit comments

Comments
 (0)