We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f9f093 commit 4cd12bcCopy full SHA for 4cd12bc
src/index.js
@@ -45,16 +45,17 @@ const handler = (req, res) => {
45
// eslint-disable-next-line no-console
46
console.error(err);
47
res.statusCode = err.status || err.statusCode || 500;
48
- res.setHeader('Content-Type', 'application/json');
+ if (!res.headersSent) {
49
+ res.setHeader('Content-Type', 'application/json');
50
+ }
51
res.end(JSON.stringify({ errors: [{message: err.message}] }));
52
return;
53
}
54
if (!res.finished) {
55
if (!res.headersSent) {
56
res.statusCode = 404;
57
- res.end(JSON.stringify({ error: `'${req.url}' not found` }));
58
+ res.end(`'${req.url}' not found`);
59
60
});
61
};
0 commit comments