I'm working with NodeJS and HTML5 pushstate. I have my index.html at "/" with a link to go to "/home/" via pushstate. All it's ok but if I refresh my page on /home/, my server return "Cannot GET /home/".
I just want "/home/" return my index.html file like "/"
My code:
var express = require("express"),
app = express();
app.use(express.static(__dirname + '/public'));
app.get('/home/', function(req, res, next) {
//what to do here?
});
app.listen(3001);
Thanks.
drop the / after/home:
app.get('/home', function(req, res, next) {
Regarding the what to do here, you can gather the data you need, and return the response. Eg: res.end("Hello world!");
If you want the static files to be served at /home, then:
app.use("/home", express.static(__dirname + "/public"));