Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Created March 8, 2022 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awswithdotnet/6d02d7f4e6e6a16ebd9881eb94b99f72 to your computer and use it in GitHub Desktop.
Save awswithdotnet/6d02d7f4e6e6a16ebd9881eb94b99f72 to your computer and use it in GitHub Desktop.
cors Startup UseService
public static void UseService(IApplicationBuilder app, IConfiguration configuration)
{
bool enableCors = bool.Parse(configuration["cors:enabled"] ?? "false");
bool allowAnyOrigin = bool.Parse(configuration["cors:allowAnyOrigin"] ?? "false");
if (enableCors)
{
if (allowAnyOrigin)
{
app.UseCors("AllowAnyOrigin");
}
else
{
app.UseCors("AllowSpecificOrigins");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment