summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/seven-suits-sit.md5
-rw-r--r--packages/astro/src/core/app/node.ts5
2 files changed, 8 insertions, 2 deletions
diff --git a/.changeset/seven-suits-sit.md b/.changeset/seven-suits-sit.md
new file mode 100644
index 000000000..ca5570843
--- /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.
diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts
index c7e6f1eca..17d800b1d 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<string, any>;
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);