Cloudflare 520 error

My sites has random 520 errors, not on every page, but it was mostly on the endpoint /api/upload/.
Im handling file uploads on this endpoint and i use cloudflare r2. Im not getting any errors on my proxy, backend and frontend. I do not know what to do.

Edit: I know what the issue is: the when the file size is like too big (about 5mb) and the request is pending to long, it will return the 520 error, the problem is i do not know how to fix it or where the error is.
It could be in my frontend, backend or reverse proxy.

A 520 error occurs when the connection started on the origin web server, but that the request was not completed. The most common reason why this would occur is that either a program, cron job, or resource is taking up more resources than it should causing the server not to be able to respond to all requests properly.

Review the Quick Fix Ideas in this Community Tip for troubleshooting suggestions.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.