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();