Category: Next.js, React and TypeScript

Next.js Server Action rejects larger form or attachment

Read this guide in Polish

A small form works and sending more fields or a file ends in a request size limit error. Server Actions have settings limiting the size of the data transmitted and are not automatically the best way to large files.

How to determine the source of the error

Check the actual body size on the Network and the error content on the server.

Determine if there is a file, base64 or repeated large JSON instead of the fields themselves.

What to do step by step

1. Move a large upload to a properly secured storage or separate endpoint; in Server Action, transfer the file identifier.

2 . If this is a justified small increase in data, configure the appropriate limit after risk assessment and add size validation.

How to check the score

The correct size form passes and exceeding the limit gives a readable message instead of an error of 500.

What to do

Do not raise the limit to any value globally, because it increases the cost and the surface of the attack.