Support files other than index.html at server root

This commit is contained in:
ansuz 2016-08-16 17:28:49 +02:00
parent 7eaa4ce733
commit eb797aa7cd
1 changed files with 4 additions and 3 deletions

View File

@ -43,9 +43,10 @@ var handleFile = function (target, res, fallback, next) {
app.use("/customize", Express.static(__dirname + '/customize')); app.use("/customize", Express.static(__dirname + '/customize'));
app.use("/customize", Express.static(__dirname + '/customize.dist')); app.use("/customize", Express.static(__dirname + '/customize.dist'));
app.use(/^\/$/, function(req, res, next) { app.use(/^\/[^\/]*$/, function(req, res, next) {
handleFile(__dirname + '/customize/index.html', // try piping this file first var file = req.originalUrl.slice(1) || 'index.html';
res, __dirname + '/customize.dist/index.html', // if it doesn't exist handleFile(__dirname + '/customize' + file, // try piping this file first
res, __dirname + '/customize.dist/' + file, // if it doesn't exist
next); // finally, fall through next); // finally, fall through
}); });