From f56781fa47a0f958b228e4a51bb3cbf173854f12 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 22 Jan 2024 16:51:15 -0500 Subject: [PATCH] fix: only disallow body with GET/HEAD requests (#11710) Co-authored-by: Rich Harris --- .changeset/four-insects-play.md | 5 +++++ packages/kit/src/exports/node/index.js | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/four-insects-play.md diff --git a/.changeset/four-insects-play.md b/.changeset/four-insects-play.md new file mode 100644 index 000000000000..da3cc35f3994 --- /dev/null +++ b/.changeset/four-insects-play.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: only disallow body with GET/HEAD diff --git a/packages/kit/src/exports/node/index.js b/packages/kit/src/exports/node/index.js index 8a9add147c78..77f2a0354ad6 100644 --- a/packages/kit/src/exports/node/index.js +++ b/packages/kit/src/exports/node/index.js @@ -110,9 +110,9 @@ export async function getRequest({ request, base, bodySizeLimit }) { method: request.method, headers: /** @type {Record} */ (request.headers), body: - request.method === 'POST' || request.method === 'PUT' || request.method === 'PATCH' - ? get_raw_body(request, bodySizeLimit) - : undefined + request.method === 'GET' || request.method === 'HEAD' + ? undefined + : get_raw_body(request, bodySizeLimit) }); }