garmeeh / local-cors-proxy

Simple proxy to bypass CORS issues.
MIT License
328 stars 81 forks source link

Handle invalid connection #31

Closed aidando73 closed 2 years ago

aidando73 commented 2 years ago

Thanks for the package - very useful.

Currently, the server throws and exits when it can't connect to the server. I think it would be better for proxy to continue operation when it can't connect to the server, since it's a very common case. Sometimes the other server is still booting up - may be temporarily down - or you forgot to turn it on. It currently throws:

internal/streams/legacy.js:61
      throw er; // Unhandled stream error in pipe.
      ^

Error: connect ECONNREFUSED 127.0.0.1:8080
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8080
}
lcp --proxyUrl http://localhost:8080 exited with code 1

And also a nice error message would be good too something like "Cannot connect to http://localhost:8080"

aidando73 commented 2 years ago

Going to close this issue - let me know if you need it back up again.