Getting Backbone and Express routes playing nicely
backbone.js, express, node.js
Solution
You possibly have two related problems: you are using push state client-side (i.e. using "real" URLs, not hash fragments such as /app#overview) but (maybe) have not enabled push state in Backbone, and your express configuration does not respond to those client-side routes.
Using push state URLs, you still have to handle those URLs server-side, since the user may visit your website using these direct "client-side" URLs (something that doesn't happen with hash fragments, since the hash part is never sent to the server).
So to fix the server-side handling, express allows using regular expressions as routes, so instead of:
app.get('/app', function(req, res) {
// Render the app...
});
You could do (see here):
// The regexp could be a little more restrictive, obviously, but you get the point...
app.get(/^\/app(\/\w+)*$/, function(req, res) {
// Render the app...
});
So that no matter which /app/* URL is used as entry-point to your web app, it gets served the necessary content.
Then in your Backbone initialization client-side, you should start the history management using `Backbone.history.start({pushState: true})` so that push state is enabled. See here.
Problem
I have an express app serving the following routes ``` /login /signup / /app ``` And I want my backbone application to manage the following routes ``` /app/overview/:company_id/:date /app/rooms/:company_id/:date ``` Anyways, express serves up the base app.jade at /app and then is supposed to hand off navigation to backbone but is instead of course intercepting and giving me a route not found. How do I do this? given someone might copy and paste a url like ``` /app/overview/3/2012-12-12 ```