I am making a single paged app using express and backbone.
in my server.js I have set up REST calls using app.get / app.post / app.update etc.. and at the end of the file, I have this route to load up our front-end code.
// load our main backbone javascript file
app.get('/*', function(req, res){
// we're not sending the correct location of the file.
res.sendfile('public/index.html');
});
Everything works as planned, until I hit refresh when I'm not at localhost:3000/ If for example, I am at localhost:3000/user/300 and hit refresh, then I get this error message.
"Uncaught SyntaxError: Unexpected token < " - app.js line 2 (our backbone file)
and nothing gets loaded on the page, it is just blank.
is it not loading the file properly? any ideas why this might be happening?
`Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/r/app.js".`
This is also the error message I get in my chrome console.
Update: So I changed
Backbone.history.start({pushState: true}); to
Backbone.history.start();
and now everything works and I can refresh the page without errors. However, the URL now has a hash.. =/ Can someone recommend me a way to fix the problem so that I don't have to use hash in my url?