fix: ServerSettings liest/schreibt jetzt Config vom ContentRoot statt AppContext.BaseDirectory

Problem: systemd setzt WorkingDirectory=/app/gott (= ContentRoot),
aber AppContext.BaseDirectory zeigt auf /app/gott/publish/.
Dadurch existierten zwei appsettings.Production.json – .NET las die
eine, die Server-Settings-UI schrieb die andere. Config-Änderungen
wie PayloadLogging hatten daher keinen Effekt.

Fix: ProductionConfigPath und FallbackConfigPath werden jetzt von
app.Environment.ContentRootPath abgeleitet statt AppContext.BaseDirectory.
This commit is contained in:
Meleki committed 2026-03-09 06:48:33 +01:00
1 parent 9ce210ab0c
commit 49811585c4
1 file changed
+9 -5
+9 -5
View File
@@ -13,11 +13,11 @@ namespace Gott.Endpoints;
public static class ServerSettingsEndpoint
{
private static readonly string ProductionConfigPath =
Path.Combine(AppContext.BaseDirectory, "appsettings.Production.json");
private static readonly string FallbackConfigPath =
Path.Combine(AppContext.BaseDirectory, "appsettings.json");
// Pfade werden beim MapEndpoints gesetzt – basierend auf ContentRootPath,
// da .NET die Config-Dateien vom ContentRoot lädt (= WorkingDirectory),
// nicht von AppContext.BaseDirectory (= Executable-Verzeichnis).
private static string ProductionConfigPath;
private static string FallbackConfigPath;
// Definiert alle konfigurierbaren Properties mit Typ und Standardwert
private static readonly List<SettingDefinition> Definitions = new List<SettingDefinition>
@@ -33,6 +33,10 @@ public static class ServerSettingsEndpoint
public static void MapServerSettingsEndpoints(this WebApplication app)
{
var contentRoot = app.Environment.ContentRootPath;
ProductionConfigPath = Path.Combine(contentRoot, "appsettings.Production.json");
FallbackConfigPath = Path.Combine(contentRoot, "appsettings.json");
app.MapGet("/api/admin/server-settings", HandleGet);
app.MapPut("/api/admin/server-settings", HandleUpdate);
}