Search code examples
ngrokserver-side-renderingnetlify

Netlify and ngrok linking


I have a front-end deployed on Netlify and a back-end is deployed on localhost which is exposed using ngrok.

Is it possible to link them so that when I click on the Netlify link, it would send request to my localhost server exposed from ngrok ?


Solution

  • Netify can proxy to a dynamic backend, that is an intended use case. The problem we'll have is using "localhost" - netlify needs a valid hostname to connect to. So, if your ngrok is exposed (not firewalled) at some public IP, you can put that into your redirects configuration:

    /backend-stuff-in-this-path/* https://1.2.3.4/:splat 200!

    will send all requests to the path /backend-stuff-in-this-path/ANYTHING to the server at 1.2.3.4/ANYTHING

    This may not be incredibly useful since your machine will change IP addresses sometimes one presumes, but if you were using localhost anyway, you weren't planning to put it in production quite yet. Note that redirects are deploy-specific, so you do need to redeploy to change the location if your IP changes.