forked from MDCPS/DamageAssessment_Backend
Updat for CORS Resolution
This commit is contained in:
@ -16,6 +16,10 @@ const int intervalForCircuitBraker = 5; //5 seconds
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// CORS setup to allow requests from any origin.
|
||||
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||
}));
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
||||
builder.Services.AddScoped<ISurveysResponse, SurveyResponsesProvider>();
|
||||
@ -36,6 +40,7 @@ builder.Services.AddHttpClient<IHttpUtil, HttpUtil>().
|
||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
//builder.Services.AddSwaggerGen();
|
||||
// Add Swagger/OpenAPI documentation support.
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
// Include XML comments from your assembly
|
||||
@ -56,6 +61,8 @@ if (app.Environment.IsDevelopment())
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
// Enable CORS, authentication, and authorization middleware.
|
||||
app.UseCors("DamageAppCorsPolicy");
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
Reference in New Issue
Block a user