Next.js Discord

Discord Forum

Should i return a 400 status code for invalid server side input validation?

Unanswered
Sirex woodwasp posted this in #help-forum
Open in Discord
Sirex woodwaspOP
in the sample code provided at https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#server-side-validation-and-error-handling, we return early if the form data is invalid and set the appropriate error messages (line 17).

however the response automatically has a status code of 200 even if an error has occurred. should i respond with an error status code like 400?
if yes, how can i do it?

1 Reply