To make more explicit some of the “gotchas” here for people who may find this issue in the future:
- make sure you have the correct
Content-Type
header for your form submissions (if you’re using forms to submit files, the header is different than it is for text data) - you can’t send the
FormData
Javascript instance directly as the body of your POST; you have to encode it as a query string using theURLSearchParams
constructor or an encoding function that you write yourself - you have to have an
action
attribute in your HTML form element, and the first argument of your fetch function has to match that attribute
Thanks again, @MyManVan!