title: POST multipart/form-data to Serverless Next.js API (running on Vercel / Now.sh)
body: <p>I'm using a Vercel Serverless function to handle a file upload to Digital Ocean Spaces (identical API to AWS S3). However, I am running into issues handling multipart/form-data in the request handler.</p>
  
  <p>On the front-end I'm using fetch to post a FormData() object with files and a couple of text fields. When logging the body and servers on the header, I can see everything there as expected, however when handling the multipart with Multer (I have also tried a couple of other similar packages) I am not able to retrieve any of the posted fields or files.</p>
  
  <p>Also worth noting is that when using Postman to test the POST requests I'm running into the exact same issue, so I'm confident the issue lies in the serverless function.</p>
  
  <h2>Front-end:</h2>
  
  <pre><code>const handleSubmit = async (values) =&gt; {
      const formData = new FormData();
  
      // build my Form Data from state.
      Object.keys(values).forEach(key =&gt; {
        formData.append(key, values[key]);
      });
  
      const response = await fetch("/api/post-submission", {
        method: "POST",
        headers: {
          Accept: "application/json",
        },
        body: formData,
      });
      const json = await response.json();
    };
  </code></pre>
  
  <h2>Serverless handler:</h2>
  
  <pre><code>const util = require("util");
  const multer = require("multer");
  
  module.exports = async (req, res) =&gt; {
    await util.promisify(multer().any())(req, res);
    console.log("req.body", req.body); // &gt;&gt; req.body [Object: null prototype] {}
    console.log("req.files", req.files); // &gt;&gt; req.files []
  
    // Do the file upload to S3...
  
    res.status(200).json({ uploadData });
  };
  </code></pre>
  
  <h2>Expected behavior:</h2>
  
  <p>req.body and req.files should be populated with my submitted data.</p>