Skip to main content
added 164 characters in body
Source Link
Jacob
  • 1.7k
  • 10
  • 27

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.

I had the same problem when using Next.js API routes with Formidable. Like the other 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,
  },
};

I had the same problem when using Next.js API routes with Formidable. As 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.

deleted 3 characters in body
Source Link
Jacob
  • 1.7k
  • 10
  • 27

I had the same problem when using Next.js API routes with Formidable. Like the acceptedother 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,
  },
};

I had the same problem when using Next.js API routes with Formidable. Like the accepted 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,
  },
};

I had the same problem when using Next.js API routes with Formidable. Like the other 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,
  },
};
Source Link
Jacob
  • 1.7k
  • 10
  • 27

I had the same problem when using Next.js API routes with Formidable. Like the accepted 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,
  },
};