Skip to content

Instantly share code, notes, and snippets.

@nickpoorman
Created August 20, 2012 10:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nickpoorman/3402977 to your computer and use it in GitHub Desktop.
Save nickpoorman/3402977 to your computer and use it in GitHub Desktop.
Express.js Backbone.js pushState router
# if the resource is not found then forward to backbone's router
app.use (req, res) ->
newUrl = req.protocol + '://' + req.get('Host') + '/#' + req.url
res.redirect newUrl
// if the resource is not found then forward to backbone's router
app.use(function(req, res) {
var newUrl = req.protocol + '://' + req.get('Host') + '/#' + req.url;
return res.redirect(newUrl);
});
@kellyjandrews
Copy link

Out of curiosity - how did you get around routes that don't exist for a 404 error?

@kyusu
Copy link

kyusu commented Apr 25, 2014

This proved to be quite helpful. Thanks for posting this! I especially appreciate that your gist written both in Java- and CoffeeScript. Very considered.

@angelogulina
Copy link

Am I wrong or this actually make a page refresh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment