Skip to content

Instantly share code, notes, and snippets.

@chicho69-cesar
Created September 19, 2022 22:44
Show Gist options
  • Save chicho69-cesar/3eea8a077b9cf1e0a59671fe0c17be63 to your computer and use it in GitHub Desktop.
Save chicho69-cesar/3eea8a077b9cf1e0a59671fe0c17be63 to your computer and use it in GitHub Desktop.
Como habilitar los CORS en una API hecha con ASP.NET minimal API's
string CORS = "My CORS";
builder.Services.AddCors(options => {
options.AddPolicy(name: CORS, builderCors => {
builderCors.SetIsOriginAllowed(origin => new Uri(origin).Host == "localhost")
.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin();
});
});
app.UseCors(CORS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment