Merge pull request #268 from matiu/bug/404
fix double headers send on 404
This commit is contained in:
commit
8223c0aca5
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue