Website: Update Fleet website's body parser limit (#11701)

Closes: #11686
Changes:
- Updated `website/config/http.js` to increase the `limit` of the Fleet
website's body-parser to 1mb (from the default 100kb) to support Fleet
instances sending usage analytics with large amounts of JSON.
This commit is contained in:
Eric
2023-05-16 12:09:02 -05:00
committed by GitHub
parent c70872607b
commit ee133fd280
+17 -5
View File
@@ -49,11 +49,23 @@ module.exports.http = {
* *
***************************************************************************/
// bodyParser: (function _configureBodyParser(){
// var skipper = require('skipper');
// var middlewareFn = skipper({ strict: true });
// return middlewareFn;
// })(),
bodyParser: (function _configureBodyParser(){
var skipper = require('skipper');
var middlewareFn = skipper({
strict: true,
limit: '1MB',// [?] https://github.com/expressjs/body-parser/tree/ee91374eae1555af679550b1d2fb5697d9924109#limit-1
onBodyParserError: (err, req, res)=>{
// If an error occurs while parsing an incoming request body, we'll return a badRequest response if error.statusCode is between 400-500
if (_.isNumber(err.statusCode) && err.statusCode >= 400 && err.statusCode < 500) {
return res.status(400).send(err.message);
} else {
sails.log.error('Sending 500 ("Server Error") response: \n', err);
return res.status(500).send();
}
}
});
return middlewareFn;
})(),
},