增加express.js中表单数据请求的限制

时间:2018-01-05 10:39:12

标签: node.js express

我正在使用Express并以 FORM-DATA

发送请求

错误 -

PayloadTooLargeError: request entity too large
at readStream (e:\MindfulSAS\myGit\hereiam-api\node_modules\raw-body\index.js:155:17)
at getRawBody (e:\MindfulSAS\myGit\hereiam-api\node_modules\raw-body\index.js:108:12)
at read (e:\MindfulSAS\myGit\hereiam-api\node_modules\body-parser\lib\read.js:77:3)
at jsonParser (e:\MindfulSAS\myGit\hereiam-api\node_modules\body-parser\lib\types\json.js:134:5)
at Layer.handle [as handle_request] (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:317:13)
at e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:284:7
at Function.process_params (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:335:12)
at next (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:275:10)
at expressInit (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:317:13)
at e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:284:7
at Function.process_params (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:335:12)
at next (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:275:10)
at query (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\middleware\query.js:45:5)
at Layer.handle [as handle_request] (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:317:13)
at e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:284:7
at Function.process_params (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:335:12)
at next (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:275:10)
at Function.handle (e:\MindfulSAS\myGit\hereiam-api\node_modules\express\lib\router\index.js:174:3)

是他们以任何方式增加对表单数据的请求限制吗?

2 个答案:

答案 0 :(得分:4)

我认为以下内容可能会对您有所帮助

{{1}}

答案 1 :(得分:0)

使用Body Parser NPM:https://www.npmjs.com/package/body-parser

var bodyParser = require('body-parser');

 app.use(bodyParser.urlencoded({
  extended: true,
  limit: '50mb',
  parameterLimit: 100000
  }))

 app.use(bodyParser.json({
  limit: '50mb',
  parameterLimit: 100000
 }))