const MAX_SIZE = 10 * 1024 * 1024; // 10MB limit
let totalSize = 0;
for await (const chunk of event.node.req.values({ preventCancel: true })) {
totalSize += chunk.length;
// If total size exceeds limit, throw an error
if (totalSize > MAX_SIZE) {
console.error('Request too large');
return {
ok: false,
status: 413,
statusText: 'Request too large',
};
}
}
const MAX_SIZE = 10 * 1024 * 1024; // 10MB limit
let totalSize = 0;
for await (const chunk of event.node.req.values({ preventCancel: true })) {
totalSize += chunk.length;
// If total size exceeds limit, throw an error
if (totalSize > MAX_SIZE) {
console.error('Request too large');
return {
ok: false,
status: 413,
statusText: 'Request too large',
};
}
}