Set WebRootPath, enable static file serving, and upgrade to .NET 9.0

This commit is contained in:
2026-01-23 20:49:51 +01:00
parent 23505060c5
commit cec2b65c29
3 changed files with 14 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

View File

@@ -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();

Binary file not shown.