I'm developing two separate Java web apps - A is website, B is backend service. Both are deployed on different machines running Tomcat.
A accesses B using REST calls.
I have separate machines for development, test and production. How can I manage deployment on development, test and production environment for these two apps? I constantly have to change URLs in both Java and JavaScript code to point to the correct server before I deploy the apps.
Options considered: 1) I've considered using system environment variables as described here. This would work for the Java side, but in my website A there's JavaScript code that invokes the REST API of backend server B. I don't know a way to access the URL defined on Java level from my JavaScript code. Is there one?
2) Use placeholders for the URL in the code that get replaced with the actual URL during a build (ant?). Again, not sure if this will work for the JavaScript code though.
This must be a common problem, but further googling didn't give me concrete hints on what people do to solve this. Appreciate any pointers.