I had the same problem when using Next.js API routes with Formidable. Like the otherAs another answer points out, you have to remove the body parser. In Next.js, you can export a config
object and disable body parsing.
// /pages/api/form.js
import { IncomingForm } from "formidable";
export default function handler(req, res) {
// formidable logic
}
// VV important VV
export const config = {
api: {
bodyParser: false,
},
};
Note that if your project uses the newer app
router, you won’t need Formidable; you can handle form submissions using FormData
in server actions / mutations.