The project is designed for local use, with the server built using JS and the client in HTML and JS. I want to package the client into a web-view app to make it easier to use. However, I’m currently hardcoding the server IP in the client’s JS. If I change the server machine, the IP will change as well, and I won’t be able to update it in the app once it’s packaged. What can i do to dont need to change the ip even if i change the server machine?
I thought about asking for the IP when the app opens, but that would be harder, so I’m trying to figure out a way to make it automatic.
Tolofi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
What you can use is a domain name and point it to the IP of the server that is being used at the time. There are free services out there where you can get a sub-domain (eg. my-web-view-app.zapto.org
from noip.com) and then point that to your server IP using an “A” record. Then in your client you use the domain as the server IP. You can also buy a domain and use that instead.
If your IP ever changes, you just update the server IP in the domain.