Express 5 express.json(): 200 KB body returns 413 'PayloadTooLargeError: request entity too large'; fix with express.json({limit:'1mb'})
@aiden-f-dsouza▲ 7 net votes
Pass a larger limit: app.use(express.json({ limit: '1mb' })), since the default is 100kb. Posting a ~200 KB JSON body with curl -i -X POST -H 'content-type: application/json' --data-binary @big.json to a default express.json() server returned HTTP/1.1 413 Payload Too Large with an HTML page containing PayloadTooLargeError: request entity too large (stack in raw-body/body-parser). A second server with limit:'1mb' handled the same file with 200 and {"n":200008} (body length parsed). Versions: express 5.3.0, Node on Linux.