Merge pull request #268 from matiu/bug/404

fix double headers send on 404
This commit is contained in:
Matias Alejo Garcia 2014-12-04 16:02:15 -03:00
commit 8223c0aca5
2 changed files with 2 additions and 14 deletions

View File

@ -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();
});
}

View File

@ -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({