expressjs / expressjs/body-parser

Unrecognised and converted body to json

Open
#628 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
5.5k
Forks
767
Avg merge
13h 53m
Merged PRs (30d)
10

Description

## Environment information

**Version**:

```json
"dependencies": {
"body-parser": "2.2.0",
"express": "5.1.0",
}
```

**Platform**:

Linux: WSL: Linux 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Windows: Microsoft Windows NT 10.0.19045.0 x64

**Node.js version**:
v20.11.1

**Any other relevant information**:

```
const app: Express = express();

app.disable('x-powered-by');

// app.use(express.json());
app.use(bodyParser.json());

app.use('/webhook/after', (req, res) => {
console.log('zjf---after-:', req.body); // here!!!
console.log('zjf---after-:', req.query);
console.log('zjf---after-:', req.headers);
console.log('zjf---after-:', req.method);

try {
if (Buffer.isBuffer(req.body)) {
const jsonString = req.body.toString('utf-8');

const data = JSON.parse(jsonString);

console.log('zjf---after-req.body:', data);
}
} catch (error) {}

res.status(200).send('OK');
});
```

Running in a container where the base image is almalinux.

Test it use Curl:

```
curl --location '${host}/webhook/after' \
--header 'content-type: application/json;charset=utf-8' \
--data '{
"challenge": "ajls384kdjxxxx"
}'
```

Result:

Image

I am running locally and Docker is parsing it properly. I can't get you to reproduce our release environment and cloud function environment.
But please help to check what could be wrong.
thanks a lot.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.