From 600afc05c8f69439562d4fd73f418dd77643986d Mon Sep 17 00:00:00 2001 From: David Beale Date: Tue, 5 May 2015 12:17:11 +0100 Subject: [PATCH] Use custom hostname as bucket name --- lib/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/app.js b/lib/app.js index 26e0d418..e9ac59c9 100644 --- a/lib/app.js +++ b/lib/app.js @@ -5,7 +5,8 @@ var app = function (hostname, port, directory, silent, indexDocument, errorDocum logger = require('./logger')(silent), Controllers = require('./controllers'), controllers = new Controllers(directory, logger, indexDocument, errorDocument), - concat = require('concat-stream'); + concat = require('concat-stream'), + path = require('path'); /** * Log all requests @@ -24,6 +25,17 @@ var app = function (hostname, port, directory, silent, indexDocument, errorDocum })); }); + app.use(function(req, res, next) { + var host = req.headers.host.split(':')[0]; + + if (indexDocument && host !== 'localhost' && host !== '127.0.0.1') + { + req.url = path.join('/', host, req.url); + } + + next(); + }); + app.disable('x-powered-by'); /**