diff --git a/DysonNetwork.Drive/Program.cs b/DysonNetwork.Drive/Program.cs index 7da07ae..79d30a3 100644 --- a/DysonNetwork.Drive/Program.cs +++ b/DysonNetwork.Drive/Program.cs @@ -46,7 +46,7 @@ using (var scope = app.Services.CreateScope()) var tusDiskStore = app.Services.GetRequiredService(); // Configure application middleware pipeline -app.ConfigureAppMiddleware(tusDiskStore); +app.ConfigureAppMiddleware(tusDiskStore, builder.Environment.ContentRootPath); app.MapGatewayProxy(); diff --git a/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs b/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs index b2c41f5..9d85778 100644 --- a/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs +++ b/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs @@ -1,4 +1,5 @@ using DysonNetwork.Drive.Storage; +using Microsoft.Extensions.FileProviders; using tusdotnet; using tusdotnet.Interfaces; @@ -6,7 +7,7 @@ namespace DysonNetwork.Drive.Startup; public static class ApplicationBuilderExtensions { - public static WebApplication ConfigureAppMiddleware(this WebApplication app, ITusStore tusStore) + public static WebApplication ConfigureAppMiddleware(this WebApplication app, ITusStore tusStore, string contentRoot) { // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) @@ -18,6 +19,12 @@ public static class ApplicationBuilderExtensions app.UseAuthorization(); app.MapControllers(); + app.UseDefaultFiles(); + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider(Path.Combine(contentRoot, "wwwroot", "dist")) + }); + app.MapTus("/api/tus", _ => Task.FromResult(TusService.BuildConfiguration(tusStore, app.Configuration))); return app; diff --git a/DysonNetwork.Shared/PageData/Startup.cs b/DysonNetwork.Shared/PageData/Startup.cs index ee597a4..3e463a8 100644 --- a/DysonNetwork.Shared/PageData/Startup.cs +++ b/DysonNetwork.Shared/PageData/Startup.cs @@ -8,6 +8,20 @@ namespace DysonNetwork.Shared.PageData; public static class PageStartup { + /// + /// The method setup the single page application routes for you. + /// Before you calling this, ensure you have setup the static files and default files: + /// + /// app.UseDefaultFiles(); + /// app.UseStaticFiles(new StaticFileOptions + /// { + /// FileProvider = new PhysicalFileProvider(Path.Combine(contentRoot, "wwwroot", "dist")) + /// }); + /// + /// + /// + /// + /// public static WebApplication MapPages(this WebApplication app, string defaultFile) { #pragma warning disable ASP0016