fix double headers send on 404
This commit is contained in:
parent
0bbf337cc0
commit
9b1b2ef38b
|
@ -7,13 +7,11 @@ var _getVersion = function() {
|
||||||
return pjson.version;
|
return pjson.version;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.render = function(req, res) {
|
exports.render = function(req, res, next) {
|
||||||
|
|
||||||
if (config.publicPath) {
|
if (config.publicPath) {
|
||||||
return res.sendfile(config.publicPath + '/index.html', {}, function(err) {
|
return res.sendfile(config.publicPath + '/index.html', {}, function(err) {
|
||||||
res.status(404).json({
|
return next();
|
||||||
error: err
|
|
||||||
}).end();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,16 +60,6 @@ module.exports = function(app, historicSync, peerSync) {
|
||||||
//routes should be at the last
|
//routes should be at the last
|
||||||
app.use(app.router);
|
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
|
//Assume 404 since no middleware responded
|
||||||
app.use(function(req, res) {
|
app.use(function(req, res) {
|
||||||
res.status(404).jsonp({
|
res.status(404).jsonp({
|
||||||
|
|
Loading…
Reference in New Issue