Skip to content

Commit

Permalink
Merge pull request #381 from Inist-CNRS/fix-error-body-lost
Browse files Browse the repository at this point in the history
fix: 🐛 attempts to fix lost body with proxy
  • Loading branch information
touv authored Oct 26, 2023
2 parents 0f47f4c + 671030d commit 1f0fde5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/server/errorHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import debug from 'debug';
import Parameter from '../parameter';
import { httpRequestErrorTotal } from './metrics';

const errorHandler = (request, response) => (error, code = 400) => {
Expand All @@ -9,10 +8,10 @@ const errorHandler = (request, response) => (error, code = 400) => {
return response.end();
}
const bodyResponse = JSON.stringify(error);
response.setHeader('Content-Type', 'application/json');
response.setHeader('Content-Length', bodyResponse.length);
response.setHeader('Content-Disposition', 'inline');
response.writeHead(code, { 'X-Error': Parameter.encode(error.toString()) });
response.writeHead(code, {
'Content-Type': 'application/json',
'Content-Length': bodyResponse.length,
});
return response.end(bodyResponse);
};

Expand Down

0 comments on commit 1f0fde5

Please sign in to comment.