Adding CORS policy to all micro-services
This commit is contained in:
parent
d0650c36f3
commit
17df019d55
@ -26,6 +26,10 @@ builder.Services.AddDbContext<AnswerDbContext>(option =>
|
|||||||
option.UseSqlServer("AnswerConnection");
|
option.UseSqlServer("AnswerConnection");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +39,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
@ -35,6 +35,9 @@ builder.Services.Configure<FormOptions>(o =>
|
|||||||
o.MultipartBodyLengthLimit = int.MaxValue;
|
o.MultipartBodyLengthLimit = int.MaxValue;
|
||||||
o.MemoryBufferThreshold = int.MaxValue;
|
o.MemoryBufferThreshold = int.MaxValue;
|
||||||
});
|
});
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
@ -44,10 +47,9 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.Run();
|
app.Run();
|
||||||
|
@ -27,6 +27,9 @@ builder.Services.AddDbContext<DoculinkDbContext>(option =>
|
|||||||
{
|
{
|
||||||
option.UseSqlServer("DoculinConnection");
|
option.UseSqlServer("DoculinConnection");
|
||||||
});
|
});
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@ -35,7 +38,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
@ -26,7 +26,9 @@ builder.Services.AddDbContext<EmployeeDbContext>(option =>
|
|||||||
{
|
{
|
||||||
option.UseSqlServer("EmployeeConnection");
|
option.UseSqlServer("EmployeeConnection");
|
||||||
});
|
});
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@ -42,7 +44,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
employeesProvider.SeedData();
|
employeesProvider.SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
@ -26,6 +26,9 @@ builder.Services.AddDbContext<LocationDbContext>(option =>
|
|||||||
{
|
{
|
||||||
option.UseSqlServer("LocationConnection");
|
option.UseSqlServer("LocationConnection");
|
||||||
});
|
});
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@ -43,7 +46,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
regionProvider.SeedData();
|
regionProvider.SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
@ -28,6 +28,9 @@ builder.Services.AddDbContext<QuestionDbContext>(option =>
|
|||||||
{
|
{
|
||||||
option.UseSqlServer("QuestionConnection");
|
option.UseSqlServer("QuestionConnection");
|
||||||
});
|
});
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@ -43,7 +46,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
questionProvider.SeedData();
|
questionProvider.SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
@ -47,6 +47,9 @@ builder.Services.AddDbContext<SurveyResponseDbContext>(option =>
|
|||||||
{
|
{
|
||||||
option.UseSqlServer("ResponsesConnection");
|
option.UseSqlServer("ResponsesConnection");
|
||||||
});
|
});
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@ -56,6 +59,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
@ -29,6 +29,11 @@ builder.Services.AddAuthentication(item =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => {
|
||||||
|
build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddScoped<ISurveyProvider, SurveysProvider>();
|
builder.Services.AddScoped<ISurveyProvider, SurveysProvider>();
|
||||||
@ -62,6 +67,7 @@ if (app.Environment.IsDevelopment())
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseCors("DamageAppCorsPolicy");
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user