Node.js: how to make default page to be sth. other than index.html

If you're running ExpressJS on top of Nodejs, you can serve the files statically using the static method. The first parameter is the directory and the second allows you to specify the default file.

app.use(express.static('../client/', {index: 'login.html'}))

http://expressjs.com/guide/using-middleware.html#middleware.built-in

For your specific example, you can modify the sendFile to include the root with the second parameter:

res.status(200).sendFile('login.html', { root: path.join(__dirname, '../client/') });

Tags:

Node.Js