You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The gateway:
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();
const proxy = createProxyMiddleware({
target: 'http://localhost:3001',
logLevel: 'debug'
});
app.use(proxy);app.use(express.json());
app.listen(3000, () => {
console.log('GATEWAY listening on port 3000!');
});
The target server:
const express = require('express');
const axios = require('axios');
const app = express();
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!');
});
Start both apps, then send a request:
// GET
curl http://localhost:3000
// this will print:
// [HPM] GET / -> http://localhost:3001
// Hello World!
// POST
curl -d "{'type': 'pencil'}" http://localhost:3000
// this will print:
// [HPM] POST / -> http://localhost:3001
// ******** service received POST undefined
// SERVICE GOT A POST!
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?
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
The text was updated successfully, but these errors were encountered: