Skip to content

Using angular template project. Running "ng serve" independently fails when trying to proxy request to dotnet. #45364

@AdamJonsson

Description

@AdamJonsson

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

It seems that the template angular project does not work with serving independently.

If one is running npm start from ClientApp and dotnet separately, angular can not communicate with dotnet.

Angular outputs the following when trying to call weatherforecast.
[webpack-dev-server] [HPM] Error occurred while proxying request localhost:44403/weatherforecast to http://localhost:55048/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

If the project is started only using dotnet watch or dotnet run, the project is working as expected.

Expected Behavior

Not getting any proxy errors. Should work the same as running the project using only dotnet watch or dotnet run.

Steps To Reproduce

You can follow the official documentation for creating an angular project. Here is a summery:

  • Create a new project using dotnet new angular -o my-new-app
  • Run npm install in ClientApp
  • Run npm start in ClientApp
  • Run dotnet watch or dotnet run in project root folder.
  • Go to fetch page of the example project
  • Error should not occur.

Exceptions (if any)

[webpack-dev-server] [HPM] Error occurred while proxying request localhost:44403/weatherforecast to http://localhost:55048/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

.NET Version

7.0.100

Anything else?

.NET SDK:
Version: 7.0.100
Commit: e12b7af219

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\

Host:
Version: 7.0.0
Architecture: x64
Commit: d099f075e4

.NET SDKs installed:
6.0.403 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

Labels

DocsThis issue tracks updating documentationarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-spa

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions