Hi,
Thanks for the sample code! I ended up with something similar.
I am using Spring Boot, using two different profiles while running my app: "development" and "production". I put "server.url=
https://my-production-url.com" in application-production.properties and put a small code in my main Application class that checks if this property is set or not. If not, a small Java method is invoked that obtains the ngrok URL from its locally running REST API and sets this URL as the value of "server.url" property. As Atlassian Connect Spring Boot supports the usage of property references in atlassian-plugin.json, I can simply use this property as a placeholder.
This way I can forget manual messing with URLs: the whole thing works out of the box in local development or production mode without any code changes. In development mode, I only have to be sure ngrok is running. Maybe a shell script could ensure this as in Gregory's solution.
I hope this gives some inspiration to users of Spring Boot.
Cheers,
Gabor