MEANJS : 413 (Request Entity Too Large)

后端 未结 3 1389
清歌不尽
清歌不尽 2021-01-11 13:55

I am using a MEANJS stack, I upload an image using ng-flow and save the imgsrc as base64 url.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARkAAACzCAYAAAC94Gg

相关标签:
3条回答
  • 2021-01-11 14:00

    2016, there may have been changes, i needed to 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);
    
    0 讨论(0)
  • 2021-01-11 14:01

    You can add following to express config:

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

    Basically you need to configure Express webserver to accept bigger request size. Replace 50mb with whatever maxsize you want to accept.

    Hope this helps!!!

    0 讨论(0)
  • 2021-01-11 14:02

    Recently, I confronted with this issue and I just added app.use(bodyParser.json({ limit: "50mb" })); this one line in my express app, it just worked :)

    And also one more thing don't forget to add above code line before app.use(bodyParser.json()) this otherwise, it won't work.

    Whatever you set values regarding bodyparser you've to do before the above code line.

    Because, express will go back to its default values and your change won't get effect. I hope this might help :)

    0 讨论(0)
提交回复
热议问题