Status code 413 when image size is larger than maxFileSize

System Information
  • Strapi Version: 4.2.0
  • Operating System: MacOS
  • Database: MariaDB
  • Node Version: 16.15.1
  • NPM Version: 8.12.1

I have created a new Strapi project and I have configured a maxFileSize:

config/middlewares.js

module.exports = [
  'strapi::errors',
  'strapi::security',
  'strapi::cors',
  'strapi::poweredBy',
  'strapi::logger',
  'strapi::query',
  {
    name: "strapi::body",
    config: {
      formidable: {
        maxFileSize: 487 * 1024, // multipart data, modify here limit of uploaded file size
      },
    },
  },
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];

When I try to upload a bigger image to test the change, I receive the warning:
Request failed with status code 413

I was expecting a friendly message saying something about the image size is too big. Right now, the message is not clear for our users.

@rrgt19, Have you found any resolution for this error? I’m also having the same error.

BTW, we have done it using the NGINX configuration of a server. How To Fix Error 413 in Apps Behind Nginx on AWS Elastic Beanstalk | Better Programming