Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/payload/src/utilities/handleEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export const handleEndpoints = async ({
url = `${request.url}?${search}`
} else if (request.headers.get('Content-Type') === 'application/json') {
// May not be supported by every endpoint
// Enforce request body size limit to prevent resource exhaustion
const contentLength = request.headers.get('content-length')
if (contentLength && parseInt(contentLength, 10) > 10 * 1024 * 1024) {
return new Response(JSON.stringify({ message: 'Request entity too large' }), {
headers: { 'Content-Type': 'application/json' },
status: 413,
})
}
data = await request.json()

// locale and fallbackLocale is read by createPayloadRequest to populate req.locale and req.fallbackLocale
Expand Down
Loading