在 https 上使用国际电话输入

Using intl-tel-input on https

我正在使用 intl-tel-input on a production environment. The default requests for the intl-tel-input ipinfo.io 是 HTTPS。这在我的开发环境中不会发生,因为请求是在 HTTP 中。

有什么方法可以覆盖它以便我可以在生产中使用 HTTP?

我的代码是:

var load_intlTelInput = function(){
    $("#my_phone_number").intlTelInput({
        defaultCountry: "auto"
    });
};

PS: 没有 intl-tel-input 或 ipinfo 标签。

查看 https://github.com/Bluefieldscom/intl-tel-input/blob/42b64c002da735e8c0a90f012083d0d5c67df4c4/examples/js/defaultCountryIp.js 处的 intl-tel-input 代码,请求始终作为 HTTP 调用发出,而不是 HTTPS 调用。

如果您的问题是如何通过 HTTPS 进行调用,您需要修改该代码以改为请求 https://ipinfo.io,或者您可以将其更改为调用 //ipinfo.io(无 http 或https) 以便它匹配其所在页面的协议(http 或 https)。

请注意,使用 http://ipinfo.io via HTTPS is limited to paid subscribers, so you'll also need to signup for an access token at https://ipinfo.io/pricing 然后将您的令牌添加到请求中。

intl-tel-input 的版本不允许在指定请求方面进行足够的自定义,并且在生产模式下它始终默认为 HTTPS。因为我们使用带有免费帐户的 ipinfo。我们又被阻止提出请求。

我只是更新到最新版本的软件(这不是垃圾邮件)并指定了一个自定义请求。可以在 intl-tel-input here.

的问题页面上找到更多信息