backbone.js https

2019-06-22 05:44发布

问题:

Been googling all morning but can't find an answer.

The official documentation does not even have the words "https" or "ssl" on it.

Currently I have something like:

var A = backbone.Collection.extend({
  url : "a"
});

is there a way to make the url https, without using absolute path?

回答1:

I don't think you can change the URL to HTTPS since it's just building a relative URL to your location. Why not do something like this:

var A = Backbone.Collection.extend({
  url: function() {
    return "https://" + this.document.location.host + "/a";
  }
});