Quantcast
Channel: Error: request entity too large - Stack Overflow
Viewing all articles
Browse latest Browse all 36

Answer by xab for Error: request entity too large

$
0
0

In case you have some special routes where you want to access raw request body and they are declared before the global bodyParser middlewares. You want to explicitly set the raw limit. This could be done as follows:

import express from 'express';/* Rest of the code */// Assuming you want your JSON payload raw and it gets larger than the default 100kbapp.post('/test',    express.raw({ type: 'application/json', limit: '10mb' }),    async (req, res) => {        // use `req.body` raw value i.e. verify content hash        // parse the body and use it as necessary        const parsed = JSON.parse(req.body.toString());        res.sendStatus(200);    },);

This snippet should work for express 4.18.2.


Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>