Body-Parser too large Nodejs

Viewed 6902

I am currently developing a API which should receive an image's base64, but when I try to pass this into the payload and send by POST, the Server (which by the way is made with Node, using express and body-parser as middleware) gives me the following error:

request entity too large

After searching a lot in the web, I found people saying that I should use:

bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
app.use(bodyParser.json({limit: '50mb'}));

intead of using:

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

However, by doing so, I receive this error:

Unexpected token i in JSON at position 5

Does anyone know what I am missing here? Thanks in advance!

This is a print with the object I am trying to send as an example:

Object with base64 attribute

2 Answers
Related