I’m using backbone.js on client side and express.js on server-side.
The problem is that, with backbone.js routing, the user can either have or have-not a slash before the #, which is breaking relative path in AJAX.
happy path url:
localhost:3000/ab/#/cd
// now if
// $.ajax({ "url" : "pay", ... });
// the request url would be
localhost:3000/ab/pay
All looks great in the happy path, but…
sad path url:
localhost:3000/ab#/cd
// with same AJAX, the request url becomes
localhost:3000/pay
How should I solve this problem?
Alright dumb question
Since the slash is before the #, it generates a new browser request, and is outside of backbone’s control
I can’t figure out a way to preserve the relative path, so I just did a force redirect on the backend