From af34142631c876a7eb62ff81f71e8a3f90dafee9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 22 Jan 2024 15:49:37 -0500 Subject: [PATCH] fix: ignore bodies sent with non-PUT/PATCH/POST requests (#11708) * fix: ignore bodies sent with non-PUT/PATCH/POST requests * use || --------- Co-authored-by: Rich Harris --- .changeset/smooth-kids-cover.md | 5 +++++ packages/kit/src/exports/node/index.js | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/smooth-kids-cover.md diff --git a/.changeset/smooth-kids-cover.md b/.changeset/smooth-kids-cover.md new file mode 100644 index 000000000000..414b4261271e --- /dev/null +++ b/.changeset/smooth-kids-cover.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: ignore bodies sent with non-PUT/PATCH/POST requests diff --git a/packages/kit/src/exports/node/index.js b/packages/kit/src/exports/node/index.js index f38a09358084..8a9add147c78 100644 --- a/packages/kit/src/exports/node/index.js +++ b/packages/kit/src/exports/node/index.js @@ -109,7 +109,10 @@ export async function getRequest({ request, base, bodySizeLimit }) { duplex: 'half', method: request.method, headers: /** @type {Record} */ (request.headers), - body: get_raw_body(request, bodySizeLimit) + body: + request.method === 'POST' || request.method === 'PUT' || request.method === 'PATCH' + ? get_raw_body(request, bodySizeLimit) + : undefined }); }