diff --git a/backend/FwLite/FwLiteWeb/FwLiteWebServer.cs b/backend/FwLite/FwLiteWeb/FwLiteWebServer.cs
index 29978b9dfa..7e329a25f5 100644
--- a/backend/FwLite/FwLiteWeb/FwLiteWebServer.cs
+++ b/backend/FwLite/FwLiteWeb/FwLiteWebServer.cs
@@ -74,6 +74,7 @@ public static WebApplication SetupAppServer(WebApplicationOptions options, Actio
configure?.Invoke(builder);
var app = builder.Build();
app.Logger.LogInformation("FwLite FwLiteWeb startup");
+ EnsureDataDirectoriesExist(app);
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI(o =>
@@ -134,4 +135,23 @@ public static WebApplication SetupAppServer(WebApplicationOptions options, Actio
.AddAdditionalAssemblies(typeof(FwLiteShared._Imports).Assembly);
return app;
}
+
+ ///
+ /// Creates the project and auth-cache directories up front, the way the MAUI host already does
+ /// (see FwLiteMauiKernel). FwLiteWeb never did, which was harmless while the paths defaulted
+ /// to the working directory (always present), but a host can point LcmCrdt:ProjectPath /
+ /// Auth:CacheFileName at a per-user location that doesn't exist yet — the Platform.Bible
+ /// extension does, and it can't create the directory itself. Without this, a missing directory makes
+ /// project listing (), project creation
+ /// (SQLite can't open a file under a missing directory), and MSAL cache init all fail.
+ ///
+ private static void EnsureDataDirectoriesExist(WebApplication app)
+ {
+ var projectPath = app.Services.GetRequiredService>().Value.ProjectPath;
+ Directory.CreateDirectory(projectPath);
+
+ var cacheFileName = app.Services.GetRequiredService>().Value.CacheFileName;
+ var cacheDir = Path.GetDirectoryName(cacheFileName);
+ if (!string.IsNullOrEmpty(cacheDir)) Directory.CreateDirectory(cacheDir);
+ }
}