total node.js noobie, started playing with demo codes from different tutorials and websites, and I noticed something that I do not understand ...
namely, if I have index.html in my / shared folder, then
app.get("/", function (req, res) { console.log("get /"); res.redirect("/test.html"); });
just not called. As soon as I rename index.html to index2.html, the method is called and redirected to /public/test.html
this is what i have:
var io = require('socket.io'), express = require('express'), MemoryStore = express.session.MemoryStore, app = express.createServer(), sessionStore = new MemoryStore(); app.configure(function () { app.use(express.bodyParser()); app.use(express.cookieParser()); app.use(express.session({ store: sessionStore, secret: 'secret', key: 'express.sid' })); app.use(express.static(__dirname + '/public')); });
and the rest is largely taken from this lesson: http://www.danielbaulig.de/socket-ioexpress/
The same problem occurs with any other file. If I have /public/test.html, then when I call
http:
this app.get is not called:
app.get("/test.html", app.authenticateUser, function (req, res) { console.log("get /test.html"); res.redirect("/test2.html"); });
When I delete test.html, I go to test2.html ...
The reason I'm trying to redirect is because the user has not logged in. I do not want it to open index.html, but rather I wanted to forward it to login.html, which is not possible if index.html exists. The only "solution" is to make the client side suck, I do not want index.html to load clients in the browser just to forward it to login.html, the server must handle this in my oppinion.