How to resolve the Vercel Runtime 413 Error?
Answered
rand posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/956923908022476850/7fa536d1bac3260871f5d36c1bf43e1b.webp?size=256)
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
![Avatar](https://cdn.discordapp.com/avatars/1011594178934878248/7f21d5d9f61881f95519d4d631f9b544.webp?size=256)
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](https://cdn.discordapp.com/avatars/956923908022476850/7fa536d1bac3260871f5d36c1bf43e1b.webp?size=256)
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
![Avatar](https://cdn.discordapp.com/avatars/1011594178934878248/7f21d5d9f61881f95519d4d631f9b544.webp?size=256)
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](https://cdn.discordapp.com/avatars/956923908022476850/7fa536d1bac3260871f5d36c1bf43e1b.webp?size=256)
randOP
oh, wow vercel isnt serverless environment??
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Asian black bear
It's the opposite.
You can't change the settings for serverless and Vercel is serverless.
![Avatar](https://cdn.discordapp.com/avatars/1011594178934878248/7f21d5d9f61881f95519d4d631f9b544.webp?size=256)
The Chosen One
oh sorry, I meant it is a serverless environment
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Asian black bear
So you have to use a different storage provider and can't get away with monkeypatching it.
Answer
![Avatar](https://cdn.discordapp.com/avatars/1011594178934878248/7f21d5d9f61881f95519d4d631f9b544.webp?size=256)
The Chosen One
this is why I bought vps server, can't have more than 10 seconds, and size limit
![Avatar](https://cdn.discordapp.com/avatars/956923908022476850/7fa536d1bac3260871f5d36c1bf43e1b.webp?size=256)
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](https://cdn.discordapp.com/avatars/484037068239142956/14304ea517cf304487f2cd802b5ba2ca.webp?size=256)
joulev
there is literally no way to do it on vercel. no workaround. the body size limit cannot be exceeded.
![Avatar](https://cdn.discordapp.com/avatars/1011594178934878248/7f21d5d9f61881f95519d4d631f9b544.webp?size=256)
The Chosen One
👁️
![Avatar](https://cdn.discordapp.com/avatars/956923908022476850/7fa536d1bac3260871f5d36c1bf43e1b.webp?size=256)
randOP
is there any vercel premium service for that?
@joulev
@joulev
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/14304ea517cf304487f2cd802b5ba2ca.webp?size=256)
joulev
Rent your own server