Created
September 19, 2022 22:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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