DefaultAllowCorsPolicy 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DefaultAllowCorsPolicy --version 1.0.0                
NuGet\Install-Package DefaultAllowCorsPolicy -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DefaultAllowCorsPolicy" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DefaultAllowCorsPolicy --version 1.0.0                
#r "nuget: DefaultAllowCorsPolicy, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DefaultAllowCorsPolicy as a Cake Addin
#addin nuget:?package=DefaultAllowCorsPolicy&version=1.0.0

// Install DefaultAllowCorsPolicy as a Cake Tool
#tool nuget:?package=DefaultAllowCorsPolicy&version=1.0.0                

DefaultAllowCorsPolicy NuGet Package

This NuGet package facilitates adding a default Cross-Origin Resource Sharing (CORS) policy to your ASP.NET Core projects.

Installation

To add the package to your project, you can use either the Package Manager Console or the .NET CLI:

dotnet add package DefaultAllowCorsPolicyNugetPackage

or

Install-Package DefaultAllowCorsPolicyNugetPackage

Usage

After adding the package to your project, you can register the service in your Startup.cs file as follows:

using DefaultAllowCorsPolicyNugetPackage;
using Microsoft.Extensions.DependencyInjection;

public class Startup
{
    // ...

    public void ConfigureServices(IServiceCollection services)
    {
        // Other service configurations

        // Add DefaultAllowCorsPolicy
        services.AddDefaultCors();

        // ...
    }

    // ...
}

This adds a CORS policy allowing all requests.

CORS Policy

This package adds a CORS policy that allows all headers, all methods, credentials, and allows any origin. This policy can be useful during development or in scenarios where specific security requirements are not necessary. It is recommended to customize the policy for security requirements.

services.AddCors(cfr =>
{
    cfr.AddDefaultPolicy(policy =>
    {
        policy
            .AllowAnyHeader()
            .AllowAnyMethod()
            .AllowCredentials()
            .SetIsOriginAllowed(policy => true);
    });
});

Licence

This project is licensed under the MIT License.

This sample README file provides essential information regarding the installation, usage, and CORS policy of the project.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 227 11/30/2023
1.0.0 115 11/29/2023