Set WebRootPath, enable static file serving, and upgrade to .NET 9.0
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user