Enhance configuration loading: skip example config in development and update launch settings for local debugging

This commit is contained in:
troogs
2026-09-14 15:45:24 +02:00
parent 8df4abc8a3
commit fdd7ea5a40
5 changed files with 12 additions and 6 deletions
+4 -2
View File
@@ -72,8 +72,10 @@ namespace FoodsharingSiegen.Server
// Check if the directory exists
if (Directory.Exists(configDir))
{
// Get all JSON files that start with "appsettings" in the directory and its subdirectories
var configFiles = Directory.EnumerateFiles(configDir, "appsettings*.json", SearchOption.AllDirectories);
// In local development, skip the template-only example config so a debug override
// such as ASPNETCORE_URLS can take effect without changing the container image setup.
var configFiles = Directory.EnumerateFiles(configDir, "appsettings*.json", SearchOption.AllDirectories)
.Where(file => !builder.Environment.IsDevelopment() || !Path.GetFileName(file).Equals("appsettings.example.json", StringComparison.OrdinalIgnoreCase));
// Add each file to the configuration
foreach (var file in configFiles) builder.Configuration.AddJsonFile(file, true, true);