Aspnet core 5 webpack proxy server

Since nothing much seem to have happened in this area (https://github.com/aurelia/cli/issues/986) still two years later I usually do like below when starting a new .NET5/Core project in VS2019 and that works fine as far as I’ve seen with requiring css and calling C# web apis in the same project etc.

Run “dotnet new angular” from a terminal (since there isn’t any longer an Aurelia template)

Delete the ClientApp folder (containing the Angular app)

Run “au new ClientApp” and select applicable options like webpack etc. also I chose Web rather than .NET Core since code generated using that was using some outdated stuff last time I tried, thus the “dotnet new angular” above.
I used this: Custom=>App=>WebPack=>Web=>TypeScript=>None=>Sass=>Yes=>None=>None=>Visual Studio Code=>Minimum=>No=>No

Open the csproj file and replace this line in Startup.cs:
spa.UseAngularCliServer(npmScript: “start”);
with:
spa.UseProxyToSpaDevelopmentServer(“http://localhost:8080”);
(the host/port here should match what’s at the end of the aurelia.json file).

If you named your aurelia app something else than ClientApp just change the SourcePath just above this in Startup.cs.

Since I got issues with hot reaload with the SSL enabled I unticked the Enable SSL checkbox in the Debug section of the project in Visual Studio.

Then I just run “npm install” (to download packages) and “npm start” to start the devserver with hot reloading and start the project in VS2019 with F5 as usual and can then set breakpoints either in the browser or the studio and they get hit in both.

To be able to publish the solution from VS2019 I also have to do some minor changes in the csproj file:
Replace:

with:

Remove:

3 Likes