Files
MilkyShots/MilkStream/Program.cs
REDCODE 5511bc56f2 fix: remove AspNetCore.SassCompiler to fix Docker startup crash
The native Dart binary at runtimes/linux-x64/src/dart is not
published into the runtime container, causing a crash when the
SassCompilerHostedService tries to start at runtime.

SCSS compilation now must be done manually with the  CLI
or by temporarily re-adding the package. Instructions added
to AGENTS.md.
2026-07-07 17:25:13 +02:00

30 lines
1.2 KiB
C#

var builder = WebApplication.CreateBuilder(args);
try { builder.WebHost.UseStaticWebAssets(); } catch (DirectoryNotFoundException) { }
var app = builder.Build();
if (!app.Environment.IsDevelopment()) {
app.UseHsts();
app.UseHttpsRedirection();
}
// Dynamically serve appsettings.json so the WASM client gets the correct BaseUrl
// regardless of the network environment (resolves the Docker-vs-browser network mismatch:
// the static wwwroot/appsettings.json would contain the Docker-internal hostname which the
// browser cannot resolve; this endpoint shadows that file and injects the externally
// reachable URL read from the server's own configuration).
app.MapGet("/appsettings.json", (IConfiguration config) => {
var lactoseBaseUrl = config["LactoseBaseUrl"] ?? string.Empty;
return Results.Json(new { BaseUrl = lactoseBaseUrl });
});
// Serve the Blazor WASM framework files from MilkStream.Client.
app.UseBlazorFrameworkFiles();
// Serve static files from the host's wwwroot (bootstrap, CSS, images, etc.).
app.UseStaticFiles();
// Fall back to index.html for all unmatched routes (SPA client-side routing).
app.MapFallbackToFile("index.html");
app.Run();