Blazor Server Redirect Causes blazor.web.js to not load from _framework correctly

I have a Blazor NET 8 Web Application. Currently working towards using Cookies as authentication. The login is being handled by a middleware class which does send the unauthorized user to /Login, but the blazor.web.js is not loading with an error of :

Uncaught SyntaxError: Unexpected token ‘<‘

On a Status Code 302 Redirect

I have been looking all over for answers on how to resolve this.

Service Injection:

// Collection of Services to Inject into the Application
public static IServiceCollection AddServerUI(this IServiceCollection services, IConfiguration config)
{
    // Add LdapAuthenticationService
    services.AddHttpContextAccessor();
    services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
    services.AddScoped<LdapAuthenticationService>();

    // Bind LdapRoleMappings from configuration and add LdapRoleMappingConfig
    var ldapRoleMappingConfig = new LdapRoleMappingConfig();
    config.Bind("LdapRoleMappings", ldapRoleMappingConfig);
    services.AddSingleton(ldapRoleMappingConfig);

    var ldapServerList = new LdapServerList(config);
    services.AddSingleton(ldapServerList);

    // Adds Blazor Server render mode and components
    services.AddRazorComponents()
    .AddInteractiveServerComponents();

    // Configure authentication
    services.AddCascadingAuthenticationState();
    services.AddScoped<CookieEvents>();

    services.AddAuthentication("Cookies")
        .AddCookie(options =>
        {
            options.LogoutPath = "/Logout";
            options.AccessDeniedPath = "/AccessDenied";
            options.ExpireTimeSpan = TimeSpan.FromMinutes(60); // Set the cookie expiration time
            options.SlidingExpiration = true; // Enable sliding expiration
            options.EventsType = typeof(CookieEvents);
        });

    // Configure authorization policies
    services.AddAuthorization(options =>
    {
        options.AddPolicy("RequireAdminRole", policy =>
            policy.RequireRole("Admin"));
        options.AddPolicy("RequireUserRole", policy =>
            policy.RequireRole("User"));
        options.AddPolicy("RequireManagerRole", policy =>
            policy.RequireRole("Manager"));
        options.FallbackPolicy = new AuthorizationPolicyBuilder()
        .RequireAuthenticatedUser()
            .Build();   
    });
    //services.AddSingleton<IAuthorizationMiddlewareResultHandler, AuthorizationMiddlewareResultHandler>();

    // Mud Blazor UI Library Add In
    services.AddMudServices();
    services.AddMudBlazorSnackbar();
    services.AddMudServicesWithExtensions();
    // Add ThemeService
    services.AddScoped<ThemeService>();

    // Load Controllers from /Controllers Folder
    services.AddControllers();

    // IAppConfiguration holds Object with appsettings.JSON Loaded
    services.AddSingleton<IAppConfiguration>(new ServerAppConfiguration(config));

    // Http Client
    services.AddHttpClient();
    // Service to have run only in DEV mode.
    #if DEV

    #endif

    return services;
}

// Build Configuration Injection for Application
public static WebApplication ConfigureServer(this WebApplication app, IConfiguration config)
{
    // Resolve IAppConfiguration from the services
    var appConfiguration = app.Services.GetRequiredService<IAppConfiguration>();

    // Middleware to set Path Base off BaseUrl in AppSettings.json Configuration
    var baseUrl = appConfiguration.BaseUrl;
    app.UsePathBase(baseUrl);

    // Configure the HTTP request pipeline.
    if (app.Environment.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Error", createScopeForErrors: true);
    }

    // Allow Loading of Static files from wwwroot folder
    app.UseStaticFiles();

    // Route Tables
    app.UseRouting();

    // Authentication and Authorization Configuration
    app.UseAuthentication();
    app.UseAuthorization();

    app.UseAntiforgery();
    app.UseHttpsRedirection();

    /// Configuration loading for Controllers
    app.MapControllers();

    // Maps Components to the Application in Server Render Mode
    app.MapRazorComponents<App>()
            .AddInteractiveServerRenderMode();

    return app;
}

CookieEvents.cs:

   public override Task RedirectToLogin(RedirectContext<CookieAuthenticationOptions> context)
   {
       context.RedirectUri = "/Login";
       return base.RedirectToLogin(context);
   }

App.Razor:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <base href="/" />

    <!-- CSS Library Imports  -->
    <link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
    <link href="_content/MudBlazor.Extensions/mudBlazorExtensions.min.css" rel="stylesheet" id="mudex-styles">
    <HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
    <Routes @rendermode="InteractiveServer" />

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">????</a>
    </div>

    <!-- JS Library Imports  -->
    <script src="_framework/blazor.web.js"></script>
    <script src="_content/MudBlazor/MudBlazor.min.js"></script></script>
</body>

</html>

Routes.Razor
Sets Public Layout to use with /Login

<Router AppAssembly="typeof(Program).Assembly">
    <Found Context="routeData">
        <AuthorizeView>
            <Authorized>
                <RouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)" />
            </Authorized>
            <NotAuthorized>
                <RouteView RouteData="routeData" DefaultLayout="typeof(PublicLayout)" />
            </NotAuthorized>
        </AuthorizeView>
        <FocusOnNavigate RouteData="routeData" Selector="h1" />
    </Found>
</Router>

Login.Razor

@page "/Login"
@attribute [AllowAnonymous]


I have tried using this approach:

    public class AuthorizationMiddlewareResultHandler : IAuthorizationMiddlewareResultHandler
    {
        public Task HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
        {
            return next(context);
        }
    }

But this doesn’t enforce rerouting to /Login

Looking for some advice, I have seen various suggestions around this problem but nothing is really fixing the issue here:

Rerouting to /Login, but having blazor.web.js load in correctly after rerouting.

I have not found a specific solution that matches this problem, apologize if I missed something.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật