Search code examples
javascriptserverlocalhostfetchlocal

Fetch local ressource from distant server


Let me explain the situation :

I have a local application that generate a local server (localhost with port) where I can have informations. I also have a distant VPS with a web application running on it. And my goal is to get informations from the local server to use them in my web application.

Any ideas how to do that ? I precise that I can't modify the local server/application because it's not mine.


Solution

  • ngrok is made exactly for that: exposing local servers to the public internet. Let's say your server is running on http://localhost:3000. You can run ngrok http 3000 and your server will also be accessible at an address like (http|https)://1234abcd.ngrok.io.

    Ngrok has a free plan that is really free and subscriptionless that is pretty powerful, allowing 8hr/day and 60 requests/mn (if I remember correctly), so it's pretty awesome for advanced web application prototyping.

    You can then upgrade to a paid plan, but at this point you'd rather host your local server on the internet instead. Then I'd recommend Digital Ocean for its simplicity and extensive dev doc.