Next.js Discord

Discord Forum

How to resolve the Vercel Runtime 413 Error?

Answered
rand posted this in #help-forum
Open in Discord
Avatar
randOP
Im using nextJS serverless option, and I get below vercel runtime error:

API response for /api/api_catalogue/ exceeds 4MB. API Routes are meant to respond quickly. https://nextjs.org/docs/messages/api-routes-response-size-limit
Vercel Runtime 413 Error: the response body is too large (> 4.5MB).


I see some of documetation below:
https://nextjs.org/docs/messages/api-routes-response-size-limit
https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit
https://vercel.com/guides/how-to-bypass-vercel-body-size-limit-serverless-functions

And they recommend to use another external storage for bypass and i really dont wanna do that since im so pretty lazy.
I just wanna resolve this issue by adding some configurations.

I added below code to the api router file and next config js.
//Router file
export const config = {
  api: {
    responseLimit: false,
  },
};


//next.config.js
 experimental: {
   serverActions: {
     bodySizeLimit: "100mb",
   },
// },


But still got the same problem.

Someone can help me out plz??
Answered by Asian black bear
So you have to use a different storage provider and can't get away with monkeypatching it.
View full answer

17 Replies

Avatar
The Chosen One
I don't think you can return more than 4mb in api routes on vercel since it's serverless
it states it clearly on docs
Avatar
randOP
Avatar
The Chosen One
If you are not utilizing Next.js in a serverless environment, and you're fully aware of the performance implications, you can disable this limit in your API Route. Here is how you can set responseLimit to false:
It says if you aren't using it in a serverless environment, vercel is a serverless environment
Avatar
randOP
oh, wow vercel isnt serverless environment??
Avatar
Asian black bear
It's the opposite.
You can't change the settings for serverless and Vercel is serverless.
Avatar
The Chosen One
oh sorry, I meant it is a serverless environment
Avatar
Asian black bear
So you have to use a different storage provider and can't get away with monkeypatching it.
Answer
Avatar
The Chosen One
this is why I bought vps server, can't have more than 10 seconds, and size limit
Avatar
randOP
Actually, I need to return base64 very long text
and why we store that text is because we need to update the canvas drawing in real time to the db.
Avatar
joulev
there is literally no way to do it on vercel. no workaround. the body size limit cannot be exceeded.
Avatar
The Chosen One
👁️
Avatar
randOP
is there any vercel premium service for that?
@joulev
Avatar
joulev
Rent your own server