var serviceROOT = 'http://myapisite.com/api/account/';
但我想,当我的用户使用 https
访问网站时,我的 api 更改为 'https://myapisite.com/api/account/'
我该怎么做?
最佳答案
您可以像这样使用 javascript 获取方案:
var scheme = window.location.protocol; //http: or https:
var serviceROOT = scheme + '//myapisite.com/api/account/';
关于javascript - AngularJS - 通过 SSL 更改 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30255930/