Operating System: Microsoft windows server 2019 standard
Database: Mongo DB v4.4.0
Node Version: v14.15.1
NPM Version: 6.14.8
Yarn Version:
Hello Strapi Community,
We are encountering an issue when posting large content to Strapi to persist it in a specific collection of Mongo DB. It is observed that whenever we post any data via http that is more than 1 MB, we get a error response stating " Bad request" back from Strapi.
Is there any specific file which we need to update to allow this? In our use-case, we may have a content around 5 MB as well which needs to be posted via http call to strapi.
Take a look at the parser Middleware, it’s default limit is set to 1mb, but you can extend it:
./config/middleware.js:
module.exports = {
// ...
settings: {
parser: {
// ...
formLimit: '10mb', // modify here limit of the form body
jsonLimit: '10mb', // modify here limit of the JSON body
formidable: {
maxFileSize: 100 * 1024 * 1024, // multipart data, modify here limit of uploaded file size
},
},
},
};
Unfortunately this setting does not seem to come into effect. By default there was no ‘middleware.js’ file in the ./config directory. Hence a new file was created with the required name and the content you have shared above. Post which Strapi was restarted as well.
When we try to POST a payload which was 4.7MB in size, we got a response as “documentations/:Payload Too Large” , wherein the ‘documentations’ is the collection name.
How do we confirm if this config file settings are into effect ? Is there any other settings to be enabled?
module.exports = {
// ...
settings: {
parser: {
// ...
formLimit: '10mb', // modify here limit of the form body
jsonLimit: '10mb', // modify here limit of the JSON body
textLimit: '10mb', // modify here limit of the text body
formidable: {
maxFileSize: 100 * 1024 * 1024, // multipart data, modify here limit of uploaded file size
},
},
},
};
Parser middleware uses the koa-body module, so all these options from parser are passed to it. You can view all available options here:
koa-body also uses formidable for form-data content(file uploads), you can view all it’s available options here:
I added this middleware.js, built again and restarted server. This works on my dev environment, but, on production, I cannot upload files larger than 1 MB. I get “413 Request Entity Too Large”
strapi v3.6.6
@sunnyson I am facing issues while uploading video files in Strapi. It keeps on giving error file size too big. The videos are around 18 mb or more. Can we increase the limit for uploading video as well?
I’m wondering if the technical solutions presented here are still applicable for Version 4 of Strapi.
I was running Strapi v4 locally, in development mode quickstart (so, SQLite, local storage).
I attempted to use the Media Library tool to upload a 370Mb MP4 video file, and got the 413 error.
What middleware.js (if that) changes are needed in V4?
When it comes to stuff deployed on an integration and/or production server, I know I will need to configure nginx too.
I use Strapi v4 and I need to extend the json limit to 5mb. The ./config/middleware.js now exports an array and I don’t know how to modify the settings of the parser. I greatly appreciate if you have any advice. Thanks
Does anyone know if it’s possible to do this for specific endpoints of fields? Or can it only be done globally with middleware.
For example, I only want to increase the allowed size for a specific field when it is edited in the admin console. But I’d like to keep the default restrictions on content added by users with REST requests.
Hi, i have the same problem on my Strapi v4.4.1.
Images > 1mb will not uploaded and return “An error occurred while uploading the file.”.
I have changed middlewares.js with this config but the problem persist.
Is there an alternative solution or a suggestion?