Tuesday | 21 MAY 2024
[ previous ]
[ next ]

Sveltekit File Upload Limit

Title:
Date: 2023-04-09
Tags:  

Sveltekit, specifically the node adapter, in production has a size limit for uploads. This was a bit of a hassle to figure out because the error message simple says that the JSON response started with an angle bracket. It doesn't actually dump the error anywhere.

What makes it even harder is that it only happens in production so it isn't obvious where or what the error is. I increased the file size in nginx was still having an issue.

I ultimately found out that the node adapter checks the environment for a max size and if it doesn't find anything, it will set the max to 512kb.

To increase this, you need to update the environment with a BODY_SIZE_LIMIT and set it to 0.

Update the .env file:

BODY_SIZE_LIMIT=0

Now you can restart the application and now you can upload whatever size you want.