From 692de9e544b8055b3bc5a8e6e358862a2dabf01b Mon Sep 17 00:00:00 2001 From: e01 Date: Sun, 31 Jul 2022 15:43:09 +0300 Subject: [PATCH 1/2] Do not send body with HEAD and GET on node integration --- packages/astro/src/core/app/node.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index c7e6f1ecad08..17d800b1d188 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -11,10 +11,11 @@ function createRequestFromNodeRequest(req: IncomingMessage, body?: Uint8Array): let url = `http://${req.headers.host}${req.url}`; let rawHeaders = req.headers as Record; const entries = Object.entries(rawHeaders); + const method = req.method || 'GET'; let request = new Request(url, { - method: req.method || 'GET', + method, headers: new Headers(entries), - body, + body: ['HEAD', 'GET'].includes(method) ? null : body, }); if (req.socket?.remoteAddress) { Reflect.set(request, clientAddressSymbol, req.socket.remoteAddress); From 9c1da4ab0880a9429208567b531c8c5d2afb4808 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 1 Aug 2022 10:44:30 -0500 Subject: [PATCH 2/2] Create seven-suits-sit.md --- .changeset/seven-suits-sit.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/seven-suits-sit.md diff --git a/.changeset/seven-suits-sit.md b/.changeset/seven-suits-sit.md new file mode 100644 index 000000000000..ca557084322a --- /dev/null +++ b/.changeset/seven-suits-sit.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Do not send `body` with `HEAD` or `GET` requests when using `server` output.