【问题标题】:How do I specify HTTP or HTTPS dependent on the current URL?如何根据当前 URL 指定 HTTP 或 HTTPS?
【发布时间】:2023-04-04 15:26:01
【问题描述】:

我的代码指定

this._restUrl = "http://" + this._info.host + "/app/rest/"; 

问题是我不知道在使用 SSL 时如何让它使用“https://”。如何将其转换为 http 或 https 语句?这适用于 http,因为它是正常的。

【问题讨论】:

  • 你也可以window.location.protocol + "//" + this._info...

标签: javascript https


【解决方案1】:

您可以使用相对协议:

this._restUrl = "//" + this._info.host + "/app/rest/";

Here’s a good description of those.

【讨论】:

  • 我刚刚在您的帖子之后搜索并找到了该页面。非常感谢!我找不到我要找的东西的名字。太简单了!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-25
  • 2021-12-11
  • 1970-01-01
  • 1970-01-01
  • 2011-06-29
  • 2023-03-18
相关资源
最近更新 更多