Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
Forwarding multipart/form-data using NextJS api

I am having a bit of trouble forwarding multipart/form-data using NextJS api.

async function proxy(req: NextApiRequest, res: NextApiResponse): Promise<void> {
    const { body, headers, method, url } = req;
    
    // Doing some work to handle authentication

    const rewriteUrl = url?.replace('/api/proxy', '');

    const config: AxiosRequestConfig = {
        url: rewriteUrl,
        method: method as Method,
        headers: {
            cookie: '',
            Authorization: token,
        },
        data: body,
    };

    try {
        const { data: originalData, status } = await axiosInstance(config);
        return res.status(status).json(originalData);
    } catch (err) {
        return res.status(err.status).json(err);
    }
}

export default proxy;

When calling the API directly or using non multipart/form-data network calls, no problem whatsoever. However, when proxying a multipart/form-data, I am receiving 413 Payload Too Large

request payload request header

I am have been trying to use

export const config = {
    api: {
        bodyParser: false,
    },
};

but in that case the backend API is responding with 400 telling that the file doesn't exist.

As am I adding an authentication header before forwarding the request, can this be the culprit as the content size change?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!