Updat for CORS Resolution

This commit is contained in:
Santhosh S
2023-11-10 14:09:43 -05:00
parent d0650c36f3
commit 43eb29c2e8
8 changed files with 81 additions and 11 deletions

View File

@ -6,6 +6,11 @@ using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// CORS setup to allow requests from any origin.
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
}));
// Add services to the container.
builder.Services.AddControllers();
@ -36,6 +41,9 @@ if (app.Environment.IsDevelopment())
app.UseSwaggerUI();
}
// Enable CORS, authentication, and authorization middleware.
app.UseCors("DamageAppCorsPolicy");
app.UseAuthorization();
app.MapControllers();