Skip to content

Commit 837fcf7

Browse files
committed
update middleware for jsonp
1 parent 9a685e1 commit 837fcf7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/middleware.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ module.exports = function(options){
88
var error = errors.parse(err);
99
req.error = JSON.parse(JSON.stringify(error)); //for logging of internal messages by logger
1010
console.error(req.error);
11-
res.statusCode = error.http;
12-
delete error.http; //do not show http code to users (it's send in header)
11+
if(!req.param("callback")){
12+
res.statusCode = error.http; //only non-jsonp should get http status codes other than 200
13+
delete error.http; //do not show http code to users (it's send in header)
14+
}
1315
delete error.internal; //do not show internal messages to users
1416
res.json(error);
1517
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author":"Allan Ebdrup",
33
"name":"nodeerrors",
4-
"version":"1.0.2",
4+
"version":"1.0.3",
55
"repository":{
66
"type":"git",
77
"url":"https://github.com/Muscula/nodeerrors"

0 commit comments

Comments
 (0)