From 2e92e9aa976735c3ddb647152bb9c4850136e386 Mon Sep 17 00:00:00 2001 From: Johannes Klauss Date: Tue, 28 Mar 2023 18:24:01 +0200 Subject: [PATCH] Fix: Crash in NodeApp.render if req.body is null (#6688) * Add additional null check for req.body * Add changeset --- .changeset/funny-pets-walk.md | 5 +++++ packages/astro/src/core/app/node.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-pets-walk.md diff --git a/.changeset/funny-pets-walk.md b/.changeset/funny-pets-walk.md new file mode 100644 index 000000000000..0327d43d2c3e --- /dev/null +++ b/.changeset/funny-pets-walk.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Add a additional check for `null` on the `req.body` check in `NodeApp.render`. diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index e7a3efca81ce..97d7b71d18dd 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -48,7 +48,7 @@ export class NodeApp extends App { ); } - if (typeof req.body === 'object' && Object.keys(req.body).length > 0) { + if (typeof req.body === 'object' && req.body !== null && Object.keys(req.body).length > 0) { return super.render( req instanceof Request ? req