apostrophe: PayloadTooLargeError: request entity too large when trying to POST to apostrophe-headless API
I am using apostrophe-headless, and my payloads are slightly big since I am storing images as base64 strings, so some of the requests fail with this:
PayloadTooLargeError: request entity too large
at readStream (/Users/marjan/Projects/marketplace-backend/node_modules/raw-body/index.js:155:17)
at getRawBody (/Users/marjan/Projects/marketplace-backend/node_modules/raw-body/index.js:108:12)
at read (/Users/marjan/Projects/marketplace-backend/node_modules/body-parser/lib/read.js:77:3)
at jsonParser (/Users/marjan/Projects/marketplace-backend/node_modules/body-parser/lib/types/json.js:134:5)
at Layer.handle [as handle_request] (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:317:13)
at /Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:335:12)
at next (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/Users/marjan/Projects/marketplace-backend/node_modules/body-parser/lib/types/urlencoded.js:100:7)
at Layer.handle [as handle_request] (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:317:13)
at /Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:335:12)
at next (/Users/marjan/Projects/marketplace-backend/node_modules/express/lib/router/index.js:275:10)
at self.csrf (/Users/marjan/Projects/marketplace-backend/node_modules/apostrophe/lib/modules/apostrophe-express/index.js:447:16)
I tried setting apostrophe-express.bodyParser
to {limit: '50mb', extended: true}
, but that doesn’t seem to work.
Any ideas on how to increase the request size limit?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 20 (3 by maintainers)
This seems to have worked:
better use (you can change the limit of data as you wish - for example 10mb):
app.use(bodyParser.json({limit: ‘10mb’, extended: true})) app.use(bodyParser.urlencoded({limit: ‘10mb’, extended: true}))
i tried change limit on node_module body-parser from 100kb to 10000kb and it works
This work for me
if you using Nginx on your server you should config Nginx too
workng for me thanks