AngularJS - 通过 SSL 更改 API

AngularJS - Change API by SSL

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/';