diff --git a/app/MindWork AI Studio/Program.cs b/app/MindWork AI Studio/Program.cs index 78719d2..5ef2af9 100644 --- a/app/MindWork AI Studio/Program.cs +++ b/app/MindWork AI Studio/Program.cs @@ -38,15 +38,28 @@ builder.Services.AddRazorComponents() var port = args.Length > 0 ? args[0] : "5000"; builder.WebHost.UseUrls($"http://localhost:{port}"); -var fileProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(type: typeof(Program))!, "wwwroot"); +#if DEBUG +builder.WebHost.UseWebRoot("wwwroot"); +builder.WebHost.UseStaticWebAssets(); +#endif + var app = builder.Build(); app.Use(Redirect.HandlerContentAsync); + +#if DEBUG +app.UseStaticFiles(); +#else + +var fileProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(type: typeof(Program))!, "wwwroot"); +app.UseDeveloperExceptionPage(); app.UseStaticFiles(new StaticFileOptions { FileProvider = fileProvider, RequestPath = string.Empty, }); +#endif + app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); diff --git a/app/MindWork AI Studio/Redirect.cs b/app/MindWork AI Studio/Redirect.cs index 6c279a4..1b974a3 100644 --- a/app/MindWork AI Studio/Redirect.cs +++ b/app/MindWork AI Studio/Redirect.cs @@ -14,12 +14,25 @@ internal static class Redirect return; } + + #if DEBUG + + if (path.StartsWith(SYSTEM, StringComparison.InvariantCulture)) + { + context.Response.Redirect(path.Replace(SYSTEM, CONTENT), true, true); + return; + } + + #else + if (path.StartsWith(CONTENT, StringComparison.InvariantCulture)) { context.Response.Redirect(path.Replace(CONTENT, SYSTEM), true, true); return; } + #endif + await nextHandler(); }