meanio文件服务器拒绝,mean.io - Error: 'Request entity too large'

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

I am receiving following error with mean.io application.

Error: request entity too large

To overcome this issue, I have increased the bodyParser limit with in meanio module at following location.

node_modules/meanio/lib/core_modules/server/ExpressEngine.js

// Request body parsing middleware should be above methodOverride

this.app.use(expressValidator());

this.app.use(bodyParser.json({limit: '50mb'}));

this.app.use(bodyParser.urlencoded({

limit: '50mb',

extended: true

}));

this.app.use(methodOverride());

However this is a bad practice and the changes will be lost if we upgrade the module. Can anyone suggest any alternative way to increase request limit at meanio app?

回答1:

I got this working actually it is the issue with npm meanio module in the latest version they have updated the code. You need to update the npm meanio package.After that you can able to overide the methods that are present in ExpressEngine.js file.

There is a issue opened for this on github

https://github.com/linnovate/mean/issues/1169

After this they have fixed this issue and merged the code

回答2:

Try to apply this in your app.js instead.

app.use(bodyParser.json({limit: '50mb'}));

app.use(bodyParser.urlencoded({limit: '50mb'}));

Hope this help!

回答3:

2016, none of the above worked for me until i explicity set the 'type' in addition to the 'limit' for bodyparser, example:

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

var app = express();

var jsonParser = bodyParser.json({limit:1024*1024*20, type:'application/json'});

var urlencodedParser = bodyParser.urlencoded({ extended:true,limit:1024*1024*20,type:'application/x-www-form-urlencoding' })

app.use(jsonParser);

app.use(urlencodedParser);

回答4:

What I got to work was putting those two lines directly var app = express(); like so:

```

var app = express();

app.use(morgan('dev'));

app.use(bodyParser.json({limit: "50mb"}));

app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));

```

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值