From cec2b65c29571c2d17930c636292e5e26f2d0d8f Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 23 Jan 2026 20:49:51 +0100 Subject: [PATCH] Set WebRootPath, enable static file serving, and upgrade to .NET 9.0 --- API/API.csproj | 2 +- API/Program.cs | 14 +++++++++++++- API/app.db | Bin 24576 -> 24576 bytes 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/API/API.csproj b/API/API.csproj index f8d5136..04c1619 100644 --- a/API/API.csproj +++ b/API/API.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable diff --git a/API/Program.cs b/API/Program.cs index eae49c0..b3ced90 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -2,7 +2,13 @@ using API.Database; using API.Repository.AgeGroup; using Microsoft.EntityFrameworkCore; -var builder = WebApplication.CreateBuilder(args); +var webRoot = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..", "wwwroot")); + +var builder = WebApplication.CreateBuilder(new WebApplicationOptions +{ + Args = args, + WebRootPath = webRoot +}); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); @@ -43,10 +49,16 @@ using(var scope = app.Services.CreateScope()) dbContext.Database.Migrate(); } +// Deliver frontend +app.UseDefaultFiles(); +app.UseStaticFiles(); + app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); +// Frontend Fallback +app.MapFallbackToFile("index.html"); app.Run(); diff --git a/API/app.db b/API/app.db index 459224a8bbc5eab8a6a086a33b067a644787fb32..ac5d8a8cf66dbe2965592c6752d6e4cb3ac2238e 100644 GIT binary patch delta 39 ucmZoTz}Rqral<2d2{T;-LtP_d1w%_K6ALQ?b3FrdV?%Rev(3Nc*&G1yVGAAr delta 39 ucmZoTz}Rqral<2d2~%A|BV7Xv1w%6{V?!%rQ#}g{b2DR8)6Ku+*&G1yunQ*u