简体   繁体   中英

Error: StatusCodeError: 413 - {“error”:{“code”:413,“message”:“request entity too large”}}

We have this request error where we were not able to send the request in express server even though we set parameterLimit and bodyParser.

we have tried setting parameterLimit:50000000000000, but still the same issue

app.use(bodyParser.json({limit: '15360mb', type: 'application/json'}))
app.use(bodyParser.urlencoded({limit: '15360mb', extended: true, type: 'application/json', parameterLimit: 5000000}))

We use

Node:8.9.4
body-parser: '1.18.3'
express: '4.17.0'

From docs:

request entity too large

This error will occur when the request body's size is larger than the "limit" option. The limit property will be set to the byte limit and the length property will be set to the request body's length. The status property is set to 413 and the type property is set to 'entity.too.large'.

limit

Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the bytes library for parsing. Defaults to '100kb'

So you've to increase the limit option. For example, for json , setting limit to 10 MB

bodyParser.json({ limit: '10mb' })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM