Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
PayloadTooLargeError with Limit Set

Hi I have a problem with Express.js, I need to send a base64 file to node.js, my configuraizone is what you see below, but when I send the file I get this error: PayloadTooLargeError: request entity too large! I've read that you need to set the limit on body-parsers like I did below, the fact is that it keeps happening to me how can I solve this?

Node Code:

const express = require("express");
const myParser = require("body-parser");
//const http = require('http');
const app = express();

//app.use(myParser.json({ type: 'application/*+json' }))
app.use(myParser.json());
app.use(myParser.urlencoded({
    extended: true
}));
app.use(myParser.json({limit: '200mb'}));
app.use(myParser.urlencoded({limit: '200mb', extended: true}));

//Porta predefinita Server
const RunPort = 8988;
//Avvio del server sulla porta specificata
app.listen(RunPort, function () {
    console.log("Serve run on Port: ", RunPort);
})
module.exports = app;
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In your code you have called twice to bodyParser.json() & bodyParser.urlencoded(), the problem is that the one with limit is after the calls without options, which defaults to 100kb. So when you POST something greater than 100kb that error will be thrown, since the first parser will not go to the next middleware.

You shouldn't call bodyParser[method] twice.

Remove:

app.use(myParser.json());
app.use(myParser.urlencoded({
    extended: true
}));

And leave:

app.use(myParser.json({limit: '200mb'}));
app.use(myParser.urlencoded({limit: '200mb', extended: true}));

Depending on how you're posting the base64 string, you may want to use:

app.use(myParser.text({ limit: '200mb' }));
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda