简体   繁体   English

Javascript配置服务器URL并将其存储

[英]Javascript configure Server URL and store it

I got the following setup: 我有以下设置:

A service running under a URL or IP or whatever installed inhouse on a server and a JavaScript/HTML app installed somewhere else which provides user interfaces for the service. 在URL或IP或服务器内部安装的任何内容下运行的服务,以及在其他位置安装的JavaScript / HTML应用程序的用户,该服务提供该服务的用户界面。

Now I do not want to hardcode the URL of the service in the UI-App. 现在,我不想在UI-App中对服务的URL进行硬编码。 Is there any solution or best practise to make the URL configurable on installation or first startup? 是否有任何解决方案或最佳实践来使URL在安装或首次启动时可配置?

Thanks and Cheers! 谢谢,干杯!

Save your Url in Browsers local Storage. 将网址保存到浏览器本地存储中。 On first Startup easily ask the user for the url. 在首次启动时,轻松地向用户询问网址。

// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("lastname");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM