Erweiterte Funktionalität durch Hinzufügen eines Endpunkts zur Zuweisung von Sprachen zu Cookies. Implementierte eine CORS-Richtlinie, die die Konfiguration von Ursprüngen über appsettings.json ermöglicht.
This commit is contained in:
@@ -22,6 +22,21 @@ try
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>() ??
|
||||
throw new InvalidOperationException("AllowedOrigins section is missing in the configuration.");
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("SameOriginPolicy", builder =>
|
||||
{
|
||||
builder.WithOrigins(allowedOrigins)
|
||||
.SetIsOriginAllowedToAllowWildcardSubdomains()
|
||||
.AllowCredentials()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Host.UseNLog();
|
||||
|
||||
@@ -159,7 +174,9 @@ try
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseCookieBasedLocalizer("de_DE", "en_US");
|
||||
app.UseCookieBasedLocalizer("de_DE", "en_US");
|
||||
|
||||
app.UseCors("SameOriginPolicy");
|
||||
|
||||
app.MapControllers();
|
||||
app.MapFallbackToController("Error404", "Home");
|
||||
|
||||
Reference in New Issue
Block a user