diff --git a/src/controllers/index.js b/src/controllers/index.js index 059c11d5cb..847bbcedc6 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -3,6 +3,7 @@ var async = require('async'); var nconf = require('nconf'); var validator = require('validator'); +var request = require('request'); var meta = require('../meta'); var user = require('../user'); @@ -74,7 +75,7 @@ Controllers.home = function (req, res, next) { req.params.slug = match[2]; Controllers.category.get(req, res, next); } else { - helpers.redirect(res, route); + request.get(nconf.get('url') + '/' + route).pipe(res); } } }, diff --git a/test/controllers.js b/test/controllers.js index 7cd359653d..050c15aea4 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -118,6 +118,16 @@ describe('Controllers', function () { }); }); + it('should 404 if custom homepage does not exist', function (done) { + meta.config.homePageRoute = 'thisroutedoesnotexist'; + request(nconf.get('url'), function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 404); + assert(body); + done(); + }); + }); + it('should render custom homepage with hook', function (done) { function hookMethod(hookData) { assert(hookData.req);