From 3f370c9047c5a88c0c21ddef7f5cf236495c9e4e Mon Sep 17 00:00:00 2001 From: bkmaxbaibhav Date: Thu, 9 Jul 2026 00:17:59 +0530 Subject: [PATCH] docs: clarify express.json() body parsing is not method-gated --- src/content/api/4x/api/express/index.mdx | 11 +++++++++++ src/content/api/5x/api/express/index.mdx | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/content/api/4x/api/express/index.mdx b/src/content/api/4x/api/express/index.mdx index aa033d171e..876db32b2f 100644 --- a/src/content/api/4x/api/express/index.mdx +++ b/src/content/api/4x/api/express/index.mdx @@ -94,6 +94,17 @@ may not be a function and instead a string or other user-input. + + +`express.json()` (and other body-parsing middleware) will attempt to parse a request body +regardless of the HTTP method — including `GET`, `HEAD`, and `DELETE` requests that +conventionally carry no body. When using body-parsing middleware globally with `app.use()`, +consider registering any rate-limiting or request-size-limiting middleware **before** +body-parsing middleware in the chain, and apply body-parsing only to routes that expect a +request body where possible. + + + ```cjs title="index.cjs" ins={5} var express = require('express'); var app = express(); diff --git a/src/content/api/5x/api/express/index.mdx b/src/content/api/5x/api/express/index.mdx index ea7ede8e74..46b8465fdc 100644 --- a/src/content/api/5x/api/express/index.mdx +++ b/src/content/api/5x/api/express/index.mdx @@ -102,6 +102,17 @@ may not be a function and instead a string or other user-input. + + +`express.json()` (and other body-parsing middleware) will attempt to parse a request body +regardless of the HTTP method — including `GET`, `HEAD`, and `DELETE` requests that +conventionally carry no body. When using body-parsing middleware globally with `app.use()`, +consider registering any rate-limiting or request-size-limiting middleware **before** +body-parsing middleware in the chain, and apply body-parsing only to routes that expect a +request body where possible. + + + ```cjs title="index.cjs" ins={5} const express = require('express'); const app = express();