Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

289
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda