Self hosted next 15 server action timeouts
Answered
Chow Chow posted this in #help-forum
Chow ChowOP
I'm uploading large files to a CDN through server actions and getting a server timeout. I've already increased the
bodySizeLimit in next config and I found there is the maxDuration route config option. Should I add this to all routes using this long running upload server action or is there another way?Answered by B33fb0n3
I would suggest, that you upload large files directly from your client to your file storage server.
Your current way:
Client -> Nextjs (Server Action with limit) -> File Storage Server
Suggested way:
Client -> File Storage Server
To prevent client from uploading millions of files, let your server action only create a policy to upload stuff to your file storage server.
Your current way:
Client -> Nextjs (Server Action with limit) -> File Storage Server
Suggested way:
Client -> File Storage Server
To prevent client from uploading millions of files, let your server action only create a policy to upload stuff to your file storage server.
8 Replies
@Chow Chow I'm uploading large files to a CDN through server actions and getting a server timeout. I've already increased the `bodySizeLimit` in next config and I found there is the `maxDuration` route config option. Should I add this to all routes using this long running upload server action or is there another way?
I would suggest, that you upload large files directly from your client to your file storage server.
Your current way:
Client -> Nextjs (Server Action with limit) -> File Storage Server
Suggested way:
Client -> File Storage Server
To prevent client from uploading millions of files, let your server action only create a policy to upload stuff to your file storage server.
Your current way:
Client -> Nextjs (Server Action with limit) -> File Storage Server
Suggested way:
Client -> File Storage Server
To prevent client from uploading millions of files, let your server action only create a policy to upload stuff to your file storage server.
Answer
Chow ChowOP
the CDN uses api key for uploads and I can't expose it to frontend though
I don't think they support pre-signed urls
ah ok it looks like they do, they just don't have it documented in the docs, only in a random article on their site
@Chow Chow ah ok it looks like they do, they just don't have it documented in the docs, only in a random article on their site
ah that sounds great. So you will upload it directly from the client to the file storage server?
@B33fb0n3 ah that sounds great. So you will upload it directly from the client to the file storage server?
Chow ChowOP
yep I probably can just keep the file client side and just send hash and other metadata to my server, return signed url and upload directly from there
sounds good. Happy to help
Chow ChowOP
thank you for the help 🙂