Last active
June 29, 2020 23:30
-
-
Save PradeepLoganathan/2c6d08441d91d392e446ddaf762eea3b to your computer and use it in GitHub Desktop.
Defining and adding multiple CORS policies to the middleware
This file contains hidden or 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
| readonly string CORSPolicies.PublicAPI = "corspolicy.public"; | |
| readonly string CORSPolicies.DevAPI = "corspolicy.dev"; | |
| services.AddCors(options => | |
| { | |
| options.AddPolicy(CORSPolicies.PublicAPI, | |
| builder => builder | |
| .AllowAnyHeader() | |
| .WithMethods("POST", "GET") | |
| .WithOrigins("https://domain1.com", "https://domain2.com")); | |
| options.AddPolicy(CORSPolicies.DevAPI, | |
| builder => builder | |
| .AllowAnyHeader() | |
| .AllowAnyMethod() | |
| .AllowAnyOrigin()); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment