Skip to content

Commit 88cba2f

Browse files
committed
fix: ignore bodies sent with non-PUT/PATCH/POST requests
1 parent 5137c8c commit 88cba2f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/smooth-kids-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: ignore bodies sent with non-PUT/PATCH/POST requests

packages/kit/src/exports/node/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function get_raw_body(req, body_size_limit) {
9595
});
9696
}
9797

98+
const can_have_body = ['POST', 'PUT', 'PATCH'];
99+
98100
/**
99101
* @param {{
100102
* request: import('http').IncomingMessage;
@@ -109,7 +111,9 @@ export async function getRequest({ request, base, bodySizeLimit }) {
109111
duplex: 'half',
110112
method: request.method,
111113
headers: /** @type {Record<string, string>} */ (request.headers),
112-
body: get_raw_body(request, bodySizeLimit)
114+
body: can_have_body.includes(request.method ?? '')
115+
? get_raw_body(request, bodySizeLimit)
116+
: undefined
113117
});
114118
}
115119

0 commit comments

Comments
 (0)