4

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?

4

2 に答える 2

3

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.

于 2013-02-23T02:18:30.550 に答える
1

You can use /* approach. Just have it as the last route. That way the other routes such as any service API calls will be matched before the catch all route of /* is matched. This is also how Backbone handles its routes.

于 2014-08-10T12:07:02.403 に答える