Fix blazor.web.js 404: move App.razor and Routes.razor to Host project
Root cause: App.razor was in CentralUI (Microsoft.NET.Sdk.Razor RCL) but MapRazorComponents<App>().AddInteractiveServerRenderMode() serves _framework/blazor.web.js from the host assembly (Microsoft.NET.Sdk.Web). Per MS docs, the root component must be in the server (host) project. - Move App.razor and Routes.razor from CentralUI to Host/Components/ - Add Host/_Imports.razor for Razor component usings - Make MapCentralUI generic: MapCentralUI<TApp>() accepts root component - Add AdditionalAssemblies to discover CentralUI's pages/layouts - Routes.razor references both Host and CentralUI assemblies - Fix all DI registrations (TemplateEngine services) - SCADALINK_CONFIG env var for role-specific config loading Verified: blazor.web.js HTTP 200 (200KB), login page renders with Blazor interactive server mode, SignalR circuit establishes, LDAP auth works.
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using ScadaLink.CentralUI.Auth;
|
||||
using ScadaLink.CentralUI.Components;
|
||||
using ScadaLink.CentralUI.Components.Layout;
|
||||
|
||||
namespace ScadaLink.CentralUI;
|
||||
|
||||
public static class EndpointExtensions
|
||||
{
|
||||
public static IEndpointRouteBuilder MapCentralUI(this IEndpointRouteBuilder endpoints)
|
||||
/// <summary>
|
||||
/// Maps the Central UI endpoints. The caller must provide the root App component type
|
||||
/// from the Host assembly so that blazor.web.js is served correctly.
|
||||
/// </summary>
|
||||
public static IEndpointRouteBuilder MapCentralUI<TApp>(this IEndpointRouteBuilder endpoints)
|
||||
where TApp : Microsoft.AspNetCore.Components.IComponent
|
||||
{
|
||||
endpoints.MapAuthEndpoints();
|
||||
|
||||
endpoints.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
endpoints.MapRazorComponents<TApp>()
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddAdditionalAssemblies(typeof(MainLayout).Assembly);
|
||||
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user