413 Content Too Large
Unanswered
AM posted this in #help-forum
AMOP
I'm trying to upload a file using the following API route:
(🔗 Pastebin link)[https://pastebin.com/95fjgMwC]
When I try to deploy the file (max size 20MB), I get this error:
413 Content Too Large
I've already enabled the following config in next.config.js:
…but I'm still unable to bypass the limit.
Any ideas what I might be missing?
(🔗 Pastebin link)[https://pastebin.com/95fjgMwC]
When I try to deploy the file (max size 20MB), I get this error:
413 Content Too Large
I've already enabled the following config in next.config.js:
experimental: {
serverActions: {
bodySizeLimit: '20mb',
},
}
…but I'm still unable to bypass the limit.
Any ideas what I might be missing?
35 Replies
Whiteleg shrimp
Vercel?
AMOP
actually sorry, mp4 is pasing .mov is not passing though 😮 no problems on localhost
Whiteleg shrimp
but, where are you deploying?
AMOP
it is to external backend
so i have clients which is calling the api route and api route is deploying to external backend
.mp4 works
on localhost all of them work tho
.mov is failing 😮
Whiteleg shrimp
Yeah but, is the NextJS app hosted on Vercel? Some provides have a max limit on the incoming request
AMOP
nextjs is hosted on vercel
same video in mp4 is passing successfully
on mov says content too large
Vercel's limit is 4.5MB for the body size
AMOP
yep you are right i've saw this
but
isn't this passing:
experimental: {
serverActions: {
bodySizeLimit: '20mb',
},
},
the body size limit 🤔
or is just for server actions but not for api routes?
Whiteleg shrimp
Vercel's limit can't not be changed, even if you Next config does
AMOP
hm but whats the point to have this in my config then 🤔
@AM hm but whats the point to have this in my config then 🤔
Whiteleg shrimp
For avoiding people send you massive body sizes when deploying somewhere else
Like Fly.io or Railway
It also works in Vercel for values lower to 4.5MB
You can try some of these https://vercel.com/guides/how-to-bypass-vercel-body-size-limit-serverless-functions
AMOP
so whats the idea deploy to vercel blob, call my api route, fetch from vercel blob in the api route and pass to the backend?
Whiteleg shrimp
yes
it's not the greatest DX I know
@Whiteleg shrimp it's not the greatest DX I know
AMOP
yes DX 😄
Whiteleg shrimp
you can use Uploadthing for uploading it, getting the URL, process it and then delete the file
they price only in storage and if the videos are only for processing, may be a good option
AMOP
trying with vercel blob
only for processing like i need to pass from the api route to external backend and i delete immediatelly
Whiteleg shrimp
if it is only for processing, may be uploadthing will be a better choice. vercel blob charges on storage, reads, writes and bandwidth, but uploadthing only charges on storage and if you process less than 2GB at the same time, you can use it for free (they don't pay me)
also, if your processing time is too high, to may get timeout errors from vercel