1

I am getting error after I stop my application. How can I fix this issue? For production I am using port 3000 and for development 4200.

[HPM] Error occurred while trying to proxy request /socket.io/?EIO=3&transport=polling&t=LhNBrs9&sid=CUdJnCGXlmH0WGSyAAAA from localhost:4200 to http://localhost:3000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

My procy.conf looks like this:

proxy.conf.json

{
  "/": {
    "target": "http://localhost:3000",
    "secure": false
  }

}
Tony
  • 223
  • 8
  • 20
  • Which application do you stop? If you stop the application running on port 3000 this is perfectly normal, you want to send your requests to this server but it was killed. – MrBlaise May 24 '17 at 06:57
  • I dont stop any application. My Node.js is running on port 300. – Tony Jun 28 '17 at 07:19

1 Answers1

0

Try:

{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false,
     pathRewrite: {
            "^/api/": "/"
        },
     changeOrigin: true
  }

}
Bruna
  • 1
  • Could you give some background on why this solution would work, – Arcath Dec 15 '20 at 12:23
  • Did you try it? The “changeOrigin” option set to “true” as above overrides the default behaviour of keeping the origin of the host header. Your API is on localhost but on a different port. And I just give a name to your target but I renamed with the pathRewrite (in this case, removing the /api). So if you make a request with /api, it will call http://localhost:3000/ only – Bruna Dec 15 '20 at 16:10
  • And sorry, is: "^/api/": "" – Bruna Dec 15 '20 at 16:58