Sails.js bodyParser - request entity too large on version 0.10.5

瘦欲@ 提交于 2019-12-01 06:29:34

Does anybody know the correct syntax for sails 0.10.5? Thanks a lot!

Take a look at this resolution (sails v.0.11.0, config/http.js):

module.exports.http = {

  middleware: { ... },

  bodyParser: function(){
    var opts = {
      limit:'10mb'
    }
   return require('./../node_modules/sails/node_modules/skipper')(opts);
  }
}
jianxing

You might want to add the parameterLimit option too.
Here's what work for me. Using sails.js 0.12
Somehow the bytes library parses the '10mb' string wrongly. Lazy to check out the regular expression, so I just input in a number directly.

Code snippets:

middleware: {
 order: [
   'startRequestTimer',
   'cookieParser',
   'session',
   'bodyParser',
   'handleBodyParserError',
   'compress',
   'methodOverride',
   'poweredBy',
   '$custom',
   'router',
   'www',
   'favicon',
   '404',
   '500'
 ],

 bodyParser: (function () {
     var opts = {limit:10000000, parameterLimit:10000};
     var fn;

     // Default to built-in bodyParser:
     fn = require('skipper');
     return fn(opts);
   })()
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!