Home > Software engineering >  Can't upload a file to nginx server with fetch
Can't upload a file to nginx server with fetch

Time:02-19

I have an application written with Laravel where I upload and serve some files. It worked fine until I tried to upload a file that is 124MB in size. Fetch request raises:

ERR_QUIC_PROTOCOL_ERROR.QUIC_IETF_GQUIC_ERROR_MISSING

And when I disable Experimental QUIC protocol on chrome://flags than the fetch request fails with

TypeError: Failed to fetch

There is nothing on the error.log and according to the access.log the POST request doesn't make it to the server.

The server is nginx version: nginx/1.18.0 (Ubuntu)

The relevant php settings are below. The same settings are configured for my local Xampp configuration and upload works fine on local.

max_execution_time=300
upload_max_filesize = 0
post_max_size = 0

CodePudding user response:

NGINX has a max POST size limit. Change it to client_max_body_size 256M; or what ever you need in a server or location config:

location /uploads {
   ...
   client_max_body_size 256M;
}

Don't forget to restart the service after the modification.

CodePudding user response:

Finally after trying for hours fetch request returned a response with the cause of the error. The culprit turned out to be Cloudflare. Cloudflare allows up to 100MB of uploads in the free plan. I disabled proxy for the subdomain, installed certbot for ssl and everything is working now.

  • Related