I am making some request that exceeds the limit of svelte of 512kb, I have checked this page on svelte docs https://kit.svelte.dev/docs/adapter-node#environment-variables-body-size-limit, it says that i have to set something to 0 and implement a custom check, and i am using adapter-vercel(because i have tried that env method didn't worked), idk how to do it, can someone help me with this?
Asked
Active
Viewed 53 times
1 Answers
1
Change body size limit
To remove the limit, locally, add this to a .env
file at the root of your project:
BODY_SIZE_LIMIT=0
And in Vercel, add an environment variable with the same name and value.
Note that you can also set it to a custom value in kiliobytes:
BODY_SIZE_LIMIT=1024 # 1mb
Custom check
Then you'd need to create a src/hooks.server.js
file with a handle
method that looks at the request body and rejects it if too large. Here is an example from Rich Harris:
export function handle({ event, resolve }) {
const length = +(event.request.headers.get('content-length') ?? '0');
if (length > MAX_SIZE) {
throw error(413);
}
return resolve(event);
}
Where MAX_SIZE
matches an environment variable you set.
Related post: How to increase request size made to api/+server.js

Dana Woodman
- 4,148
- 1
- 38
- 35