How to resolve the Vercel Runtime 413 Error?
Answered
rand posted this in #help-forum
randOP
Im using nextJS serverless option, and I get below vercel runtime error:
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.
But still got the same problem.
Someone can help me out plz??
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.
17 Replies
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
randOP
Yeah, but in this doc, they say we can.
https://nextjs.org/docs/messages/api-routes-response-size-limit
https://nextjs.org/docs/messages/api-routes-response-size-limit
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
randOP
oh, wow vercel isnt serverless environment??
Asian black bear
It's the opposite.
You can't change the settings for serverless and Vercel is serverless.
The Chosen One
oh sorry, I meant it is a serverless environment
Asian black bear
So you have to use a different storage provider and can't get away with monkeypatching it.
Answer
The Chosen One
this is why I bought vps server, can't have more than 10 seconds, and size limit
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.
joulev
there is literally no way to do it on vercel. no workaround. the body size limit cannot be exceeded.
The Chosen One
👁️
randOP
is there any vercel premium service for that?
@joulev
@joulev
joulev
Rent your own server