Search code examples
node.jsbackbone.jsexpress

Express router conflicting with Backbone pushstate


An Express / route serves my Backbone's app index.html.

I'm using pushstate in Backbone but the routes that Backbone should handled are being handled by express, giving 404 responses.

How can I setup Express to serve the index.html but to delegate other routes to Backbone?


Solution

  • In this situation you have multiple options:

    1. You can have a server that handles the same routes as the client does and returns the same results. It is hard to implement but it gives a good url. Github did this.

    2. Always return index.html and handle the route client side. (That is somewhat ugly and hard to maintain)

    3. Don't use pushstate. Amen.