POST request looses body #915
Replies: 4 comments
-
Not clear which issues you already looked at and what you already tried... Would be nice if you could list them. Guessing you already explored #40 (comment) and changed the order of the proxy and Alternatively you could try to configure the |
Beta Was this translation helpful? Give feedback.
-
Thanks @chimurai |
Beta Was this translation helpful? Give feedback.
-
Found 3 issues... (not related to http-proxy-middleware)
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json()); // <<<<< add missing middleware
app.get('/', (req, res) => {
res.send('Hello World!\n');
});
app.post('/', (req, res) => {
console.log('******** service received POST %s', JSON.stringify(req.body, null, 2));
res.send('SERVICE GOT A POST!\n');
})
app.listen(3001, () => {
console.log('SERVICE listening on port 3001!');
}); Issue 2 & 3:
curl -H "Content-Type: application/json" -d '{"type": "pencil"}' http://localhost:3000 After fixing those issues I'm able to receive the POST data: SERVICE listening on port 3001!
******** service received POST {
"type": "pencil"
} |
Beta Was this translation helpful? Give feedback.
-
Many thanks @chimurai ! |
Beta Was this translation helpful? Give feedback.
-
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
It seems this is an "old" issue, but I ran into it and am not able to fix it with the comments I found in the existing issues.
I have 2 express apps, all running in a (single) docker container.
The first app serves as a gateway, which should proxy incoming requests to the target server.
GET requests are proxied correctly.
POST requests seem to loose their body.
Step-by-step reproduction instructions
Expected behavior (be clear and concise)
The target server should receive the POST request with the original body
How is http-proxy-middleware used in your project?
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Everything is running in a docker container with Debian GNU/Linux 10 System: OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster) CPU: (4) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz Memory: 3.25 GB / 5.81 GB Container: Yes Shell: 5.0.3 - /bin/bash Binaries: Node: 14.21.2 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 6.14.17 - /usr/local/bin/npm Managers: Apt: 1.8.2.3 - /usr/bin/apt Utilities: Make: 4.2.1 - /usr/bin/make GCC: 8.3.0 - /usr/bin/gcc Git: 2.20.1 - /usr/bin/git Mercurial: 4.8.2 - /usr/bin/hg Subversion: 1.10.4 - /usr/bin/svn Languages: Bash: 5.0.3 - /bin/bash Perl: 5.28.1 - /usr/bin/perl Python: 2.7.16 - /usr/bin/python Python3: 3.7.3 - /usr/bin/python3
Additional context (optional)
No response
Beta Was this translation helpful? Give feedback.
All reactions