Skip to content

Commit

Permalink
use redirect to load index.html by default
Browse files Browse the repository at this point in the history
  • Loading branch information
w33ble committed Apr 22, 2014
1 parent e90c4e7 commit 65657da
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/serve/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ var rstream = require('replacestream');

module.exports = function (port, lrPort, open, next) {
var server = http.createServer(function(req, res) {
var request = (req.url === '/') ? '/index.html' : req.url;
var filePath = path.join(process.cwd(), request);
if (req.url === '/') {
res.writeHead(301, {'Location': '/index.html'});
return res.end();
}
var filePath = path.join(process.cwd(), req.url);
var mimetype = mime.lookup(filePath);
var fileStream = fs.createReadStream(filePath);

Expand Down

0 comments on commit 65657da

Please sign in to comment.