From b7e5e7d7fe5cfa2adda3271fe86543cbadd5e0f6 Mon Sep 17 00:00:00 2001 From: Santhosh S <913341@dadeschools.net> Date: Sat, 11 Nov 2023 22:00:06 -0500 Subject: [PATCH] Updated CORS with POST specific with Surveys --- .../DamageAssesment.Api.Surveys/Program.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs index c6a58a3..93545ae 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Program.cs @@ -34,9 +34,23 @@ builder.Services.AddAuthentication(item => }); // CORS setup to allow requests from any origin. -builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { - build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); -})); +//builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { +// build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); +//})); + + + +builder.Services.AddCors(options => +{ + options.AddPolicy("DamageAppCorsPolicy", builder => + { + builder.WithOrigins("*") + .AllowAnyHeader() + .WithMethods("POST") // Allowing only the POST method + .AllowAnyOrigin(); + }); +}); + // Add controller services and API Explorer for endpoint discovery. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle