Skip to content

Best way for project with multiple client applications #46145

@alkoval

Description

@alkoval

Hello,
i have an Asp.Net Core 6 project with two Angular 14 apps.
Sample project https://github.com/alkoval/AspNetCoreMultipleAngular

Client applications in the ClientApp and ClientApp2 folders.
In Startup.cs added:

           app.Map(new PathString("/clientapp2"), client =>
            {
                var path = env.IsDevelopment() ? @"ClientApp2" : @"ClientApp2/dist";
                var clientAppDist = new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), path))
                };
                client.UseSpaStaticFiles(clientAppDist);

                if (env.IsDevelopment())
                {
                    client.UseSpa(spa =>
                    {
                        spa.Options.SourcePath = "ClientApp2";
                        spa.UseAngularCliServer(npmScript: "start");
                    });
                }
                else
                {
                    client.UseSpa(spa =>
                    {
                        spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
                        spa.Options.SourcePath = "ClientApp2";
                        spa.Options.DefaultPageStaticFileOptions = clientAppDist;
                    });
                }
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });

The first client app is available at https://localhost:44313/.
The second client app is available at https://localhost:44313/clientapp2 and in dev it reloads every time. I think this is because the DevServer has created a web socket at "url wss://localhost:44313/ng-cli-ws", when need to "url wss://localhost:44313/clientapp2/ng-cli-ws".
Tell me please, how can i fix it? I would be grateful for any recommendations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsThis issue tracks updating documentationarea-ui-renderingIncludes: MVC Views/Pages, Razor Views/Pagesfeature-spa

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions