Nx: Proxy error for a fresh Nx + Nestjs project

Created on 3 Apr 2019  路  5Comments  路  Source: nrwl/nx

Prerequisites

  • [ x] I am running the latest version
  • [ x] I checked the documentation and found no answer
  • [x ] I checked to make sure that this issue has not already been filed
  • [x ] I'm reporting the issue to the correct repository (not related to Angular, AngularCLI or any dependency)

Expected Behavior

I expect to start blank application when running ng serve appname

Current Behavior

The app compiles and runs, but I get an error in the console when I open the app in my browser at http://localhost:4200

[HPM] Error occurred while trying to proxy request /api/hello from localhost:4200 to http://localhost:3333 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. npx create-nx-workspace appname
  2. selected nestjs app during installation
  3. cd appname
  4. ng serve appname

Context

Please provide any relevant information about your setup:

  • version of Nx used latest
  • version of Angular CLI used 7.3.1

Failure Logs

[HPM] Error occurred while trying to proxy request /api/hello from localhost:4200 to http://localhost:3333 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Opening Chrome Dev console, in the Network section, the request to /api/hello returns the following message:
Error occured while trying to proxy to: localhost:4200/api/hello

Another question, while I'm here, is there a canonical way to upgrade Nestjs to 6.0, as the current installation uses 5.5? Or should I wait for nx to publish upgrade to 6.0?

Most helpful comment

My bad, I didn't know I was supposed to do ng serve api as well.

All 5 comments

My bad, I didn't know I was supposed to do ng serve api as well.

:+1:

Adding more info that might help new comers/first timer

In CLI (Terminal for e.g.) open new tab

user@host:/path/to/your/workspace$ ng serve api

Although I have got the usage on launching api server and angular application separately, I'm still curious that whether there would be cons or risky problems if merge serving angular and api/nest server into one npm script ?

I got caught out by this as a newby. Saved with thanks to this issue

馃憤

Adding more info that might help new comers/first timer

In CLI (Terminal for e.g.) open new tab

user@host:/path/to/your/workspace$ ng serve api

still a valid point

Was this page helpful?
0 / 5 - 0 ratings