Presenting My Router:
var MyRouter = Backbone.Router.extend({
initialize: function(){
Backbone.history.start({ pushState:true });
},
routes: {
'hello' : 'sayHello'
},
sayHello: function(){
alert('Saying hello');
}
});
Observe, I've opted for { pushState:true }
to offer URLs without hash fragments.
In addition, I'm utilizing a Node.js server for managing routes:
var express = require('express');
var app = express();
app.use(express.static(__dirname));
app.listen(3010);
Upon navigating to the route http://localhost:3010#hello
, my browser converts it to http://localhost:3010/hello
and functions as expected. However, when directly accessing http://localhost:3010/hello
, I encounter a Cannot GET /hello
error.
This issue likely has a simple solution, but can anyone provide insights into where I may be going wrong?
Thank you in advance.