Page 1 of 1

Ngrok and Rest API

PostPosted: Fri Jun 19, 2020 4:11 pm
by SBarnes
Interesting thing I have discovered whilst attempting to setup ngrok (https://ngrok.com/) with the rest api to come back to local host, when you get the metadata page to come up which it will do quite happily any link you click on is unfortunately not going to work because the URLs have been derived to include the port number so http://ZZZZ-----.ngrok.io gets translated to http://ZZZZ-----.ngrok.io:81 if 81 is the port you are bound too.

Is this likely to be an issue with routes themselves on the api or is this just a symptom of the ServiceStack plugins that generate the web interface?

Re: Ngrok and Rest API

PostPosted: Fri Jun 19, 2020 5:35 pm
by Scott.Pearce
Sounds like a problem with ngrok to me.

Re: Ngrok and Rest API

PostPosted: Fri Jun 19, 2020 5:51 pm
by Mike.Sheen
It does look like ngrok isn't rewriting the URL properly.

ngrok is really acting like a proxy, and whilst it is rewriting the URLs in responses, it's not considering the port number - which is a valid part of the URL.

Re: Ngrok and Rest API

PostPosted: Fri Jun 19, 2020 6:22 pm
by SBarnes
I'd say you are right if you go to page source its replaced local host with ngrok url but not the :81.

I am looking at being able to work with incoming webhooks for development locally, given I've already gotten it to work ap.net webhook receivers I think it should work with the api as well without a problem.

Re: Ngrok and Rest API

PostPosted: Fri Jun 19, 2020 7:24 pm
by Mike.Sheen
SBarnes wrote:I'd say you are right if you go to page source its replaced local host with ngrok url but not the :81.


Yes - I should have mentioned I went to the effort of creating an ngrok account, downloading the windows app and testing it out with a locally running Jiwa self hosted REST API service on port 81 as you described - and I could see it was rewriting the URL's, but it was including the port number of the base URL when I think it shouldn't have been.

Re: Ngrok and Rest API

PostPosted: Fri Jun 19, 2020 8:20 pm
by SBarnes
So long as it will redirect to local host which I believe it should for an api call it should be ok for testing incoming hooks, the other is an annoyance that I can live with, fortunately one little neat feature that ngrok says it does is it creates a https link through to straight http as well which is good in a case of any platforms where https is mandatory for their webhooks.