If you are using valet, then 'valet share' will open an ngrok tunnel to your server (basically giving you a publicly addressible URL).
Now the API should work over the new ngrok url the same way as accessing it over 127.0.0.1.
If you are not using valet, you can still go to https://ngrok.com, create an account and follow instructions on how to create an ngrok tunnel to your local server.
First test with http.
To use https, you have to use 'valet secure' to create an encrypted connection. If not using valet, there are ways of creating a secure channel with MAMP & WAMP as well.
There are a couple of issues that took me a while to resolve which had to do with reinitializing the server and clearing the DNS cache. To avoid these, do the following:
-
After you create a secure channel, restart your server. (restart valet or MAMP or better still, reboot your computer).
-
Clear your DNS cache. On a mac, dscacheutil -flushcache && sudo killall -HUP mDNSResponder will do it.
Now your API should work over a secure virtual server.