I am building a system that will pull 2 variables from the url (variable1.domain.com/variable2).
I cannot find any documentation showing how to do anything with subdomains in backbone. Default_url is just passed as domain.com/api. I did find something called CORS (www.enable-cors.org) that enables cross domain calls, but it says nothing about dynamic domains.
Is something like this even possible with backbone? If not, does anyone know if ember.js or other backbone-like systems have this “feature”?
This is certainly possible but not within the scope of Backbone’s default behavior. Assuming that all your subdomains utilize the same router code, you could hack up a solution that might look like this:
One important caveat with this approach: it works fine for users navigating to URLs themselves, but will quickly become wonky when your application needs to perform a
navigatecall to theRouter. Backbone will navigate only to hash portion of the URL, so it will not include subdomain. You would probably have to spin up a custom navigation function that setswindow.locationbefore doing anything else.Obviously this is probably not something Backbone is well-suited for. I’m unsure if Ember or anything else has this functionality, but I would doubt it. Subdomains are meant to be distinct areas of your site, so you might not be using them correctly.