可以通过配置来设置大小,修改配置文件:
exports.bodyParser = {
jsonLimit: '5mb',
formLimit: '6mb',
};
默认配置:
/**
* The option of `bodyParser` middleware
*
* @member Config#bodyParser
* @property {Boolean} enable - enable bodyParser or not, default is true
* @property {String | RegExp | Function | Array} ignore - won't parse request body when url path hit ignore pattern, can not set `ignore` when `match` presented
* @property {String | RegExp | Function | Array} match - will parse request body only when url path hit match pattern
* @property {String} encoding - body's encoding type,default is utf8
* @property {String} formLimit - limit of the urlencoded body. If the body ends up being larger than this limit, a 413 error code is returned. Default is 100kb
* @property {String} jsonLimit - limit of the json body, default is 100kb
* @property {Boolean} strict - when set to true, JSON parser will only accept arrays and objects. Default is true
* @property {Number} queryString.arrayLimit - urlencoded body array's max length, default is 100
* @property {Number} queryString.depth - urlencoded body object's max depth, default is 5
* @property {Number} queryString.parameterLimit - urlencoded body maximum parameters, default is 1000
*/
config.bodyParser = {
enable: true,
encoding: 'utf8',
formLimit: '100kb',
jsonLimit: '100kb',
strict: true,
// @see https://github.com/hapijs/qs/blob/master/lib/parse.js#L8 for more options
queryString: {
arrayLimit: 100,
depth: 5,
parameterLimit: 1000,
},
};
可以查找 egg.js 文档中的
config.bodyParser