From 9b1b2ef38bceaf719fe737e78cf5d1b354817ec5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 4 Dec 2014 15:53:04 -0300 Subject: [PATCH] fix double headers send on 404 --- app/controllers/index.js | 6 ++---- config/express.js | 10 ---------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/app/controllers/index.js b/app/controllers/index.js index 52e67fe7..1b084232 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -7,13 +7,11 @@ var _getVersion = function() { return pjson.version; }; -exports.render = function(req, res) { +exports.render = function(req, res, next) { if (config.publicPath) { return res.sendfile(config.publicPath + '/index.html', {}, function(err) { - res.status(404).json({ - error: err - }).end(); + return next(); }); } diff --git a/config/express.js b/config/express.js index 78b1f436..8de62c81 100644 --- a/config/express.js +++ b/config/express.js @@ -60,16 +60,6 @@ module.exports = function(app, historicSync, peerSync) { //routes should be at the last app.use(app.router); - //Assume "not found" in the error msgs is a 404 - app.use(function(err, req, res, next) { - if (~err.message.indexOf('not found')) return next(); - console.error(err.stack); - res.status(500).jsonp({ - status: 500, - error: err.stack - }); - }); - //Assume 404 since no middleware responded app.use(function(req, res) { res.status(404).jsonp({