Front-end file upload 413 Request Entity Too Large error report solution

1. Problem: In local development, both small and large files can be uploaded successfully, but after the code is released to the test environment, an error will be reported for files exceeding 1mb. Open the console to see 413 Request Entity Too Large.

2. Check our system interface and do a forward proxy at the node layer, using koaBody

app.use(
  koaBody({
    parsedMethods: ['POST', 'PUT', 'PATCH', 'DELETE'],
    formLimit: '50mb',
    jsonLimit: '50mb', // ajax 请求
    textLimit: '50mb',
    multipart: false,
    formidable: {
      maxFieldsSize: 10 * 1024 * 1024
    },
  })
);

The front-end restriction is lifted, and the package is repackaged and launched, but the error 413 Request Entity Too Large is still reported

Continue to check:

By default, Nginx can upload files up to 1MB. Files larger than 1MB cannot be uploaded naturally. Open nginx.conf (with no permission to find operation and maintenance personnel) and set in http{ }: client_max_body_size 50m.

Solved successfully!

Guess you like

Origin blog.csdn.net/lovecoding1/article/details/128217487