Search code examples
angularportforwardingngrok

how to force ngrok to send requests back to localhost


I ran ngrok on my remote server port 4200 but the issue I'm facing is that my angular frontend is communicating to another API set up on the same remote server "localhost:5556/getAll"

I have 2 docker containers running on my remote server:

user_interface => running on HTTP://localhost:4200/
backend_api => running on HTTP://localhost:5556/

I'm currently serving the user interface on ngrok and its giving me a URL where I can access it from my local machine but the issue is that the user_interface is calling the backend_api on port 5556 to get information and display it on the web page but when I open the network tab it's calling localhost:55556/ not the URL provided by ngrok ex: http://abcccc.ngrok.io:5556

how can I force ngrok to forward requests from the angular frontend back to the same machine I deployed it on


Solution

  • I don't think the solution is to "force" ngrok to forward requests to a different machine. ngrok just does what it does and forwards requests sent to the front of a tunnel through to a backend service.

    It seems like you probably just need to configure your angular application to access your backend_api service using an ngrok hostname and port, whereas currently the frontend user interface is configured to make backend requests to localhost.