diff --git a/Endpoints/ServerSettingsEndpoint.cs b/Endpoints/ServerSettingsEndpoint.cs index 94409a9..ad05311 100644 --- a/Endpoints/ServerSettingsEndpoint.cs +++ b/Endpoints/ServerSettingsEndpoint.cs @@ -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 Definitions = new List @@ -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); }