ZECTBynmo
ZECTBynmo

Reputation: 3367

How does Express handle routes, and what does the '#' do?

I've setup an Express server using backbone.js with a couple routes, and I'm trying to capture information through the url using req.params.

I've setup my server with appropriate routing

app.get( '/route/:first/:second', router.routeHandler );

With my express server, when I type in a url like this: http://localhost:3000/route/firstVar/secondVar

I get raw JSON returned to me, but when I try a url like this: http://localhost:3000/#route/firstVar/secondVar

it will actually render the html and CSS to the page. What is going on there? Can I change that behavior? Where is that setup?

Upvotes: 1

Views: 95

Answers (1)

ajk
ajk

Reputation: 4603

Nothing after the hashmark is making its way to the server. If you want to be able to handle that second URL, you'll need to set up the proper routes on the client-side (in your case, using Backbone). Have a peek at Backbone's History and Router documentation for some more information.

Upvotes: 1

Related Questions