Next.js Discord

Discord Forum

413 (Payload Too Large)

Unanswered
Broad-snouted Caiman posted this in #help-forum
Open in Discord
Avatar
Broad-snouted CaimanOP
experimental: { serverActions: { bodySizeLimit:"10mb" }, // ppr:true, }, even through I have next.conifg.js modified like this - I am still getting this error in production(file size is not more than 10mb)

14 Replies

Avatar
is your app hosting on vercel or self hosting?
Avatar
Broad-snouted CaimanOP
vercel
Avatar
how large is the file?
the body size contain all the form field you are posting
Avatar
Broad-snouted CaimanOP
Actually it might be more than 10mb because I am passing 2 images instead of 1
let me re-check
I remembered that I was passing only 1
Avatar
Broad-snouted CaimanOP
@Ray Still getting same error on 15mb size, images are not over 15mb
Avatar
can you show the code of your server action?
Avatar
Broad-snouted CaimanOP
export const generateEdit = async (data:FormData, prompt: string,) => { console.log('aeee') try { const response = await openai.images.edit({ image: data.get('main') as File, prompt: prompt, mask: data.get('mask') as File, model: "dall-e-2", n: 4, response_format: "b64_json", size: "1024x1024" }) return response.data } catch (e) { throw new Error(e as string) } }
Avatar
Broad-snouted CaimanOP
maybe they disabled that feature because of Vercel Blob?
Avatar
i think the 413 is return from openai
try this
export const generateEdit = async (data:FormData, prompt: string,) => {
  console.log('aeee')
  try {
    const response = await openai.images.edit({
      image: await (data.get('main') as File).arrayBuffer(),
      prompt: prompt,
      mask: await (data.get('mask') as File).arrayBuffer(),
      model: "dall-e-2",
      n: 4,
      response_format: "b64_json",
      size: "1024x1024"
    })
    return response.data
  } catch (e) {
    throw new Error(e as string)
  }
}
Avatar
Checkered Giant
Hey, I've also got an issue with server actions payload being too large. I added the config setting as suggested above but all files result in the error. Any ideas on potential solutions? The request is a fetch API call. More context: I'm uploading an audio file and sending the buffer data to openAI whisper. I'm not intending on storing the files.