0

If I am serving my Backbone application from http://example.com/foo/bar.html, what should I specify the application root as? E.g.:

Backbone.history.start({
    pushState: true,
    root: '/foo/'
});

vs

Backbone.history.start({
    pushState: true,
    root: '/foo/bar.html'
});

In fact, does it even matter as far as Backbone routing and history are concerned?

I notice that if I use the former form, images with relative URLs become broken because pushState would cause the (apparent) location of the window to change to a string like /foo/login, and then a relative URL like img/orange_cat.jpg gets resolved to /foo/login/img/orange_cat.jpg by the browser, when I really want /foo/img/orange_cat.jpg.

Kal
  • 1,707
  • 15
  • 29

1 Answers1

0

The first form is the correct one.

To fix the broken images issue

And add this to your head tag

<base href="/foo/" />
Community
  • 1
  • 1
Ahmad Alfy
  • 13,107
  • 6
  • 65
  • 99