Angular HPM localhost error from while trying to proxy request /api/books from localhost:4200 to http://localhost:3333

Viewed 4814

Been trying for a few hours to get this issue fixed but cant make a post request with this error. At first i was using ng serve but then started using npm start but still got errors.

Error:

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

My proxy file:

{
  "/api/*": {
    "target": "https://localhost:4200",
    "secure": false,
    "changeOrigin": true,
    "logLevel": "debug"
  }
}
2 Answers

Is this issue with NX Monorepo ? If yes, you are just running this command :

ng serve

In a new tab of terminal, also run the command :

ng serve api

Since both servers need to be started.

port 4200 is your app running on, isn't it? so then you have to change target url in proxy file to localhost:3300.

Related