Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requests with a body don't work #417

Closed
SoulKa opened this issue Mar 27, 2020 · 2 comments · Fixed by #492
Closed

Requests with a body don't work #417

SoulKa opened this issue Mar 27, 2020 · 2 comments · Fixed by #492

Comments

@SoulKa
Copy link

SoulKa commented Mar 27, 2020

Is this a bug report?

Yes

Steps to reproduce

  1. Setup the project as written in the readme
  2. Create an endpoint to check if the request succeeds (mine is on https://webhook.site)
  3. Execute a request with no body (using postman) => succeeds
  4. Execute the same request with a body (using postman) => timeout/ no response

The request:
http://127.0.0.1/proxy/MY-WEBHOOK-IDENTIFIER

Expected behavior

forward http://127.0.0.1/proxy/MY-WEBHOOK-IDENTIFIER to https://webhook.site/MY-WEBHOOK-IDENTIFIER no matter what content:

No timeout when requesting on http://127.0.0.1/proxy/MY-WEBHOOK-IDENTIFIER with a content
No timeout when requesting on http://127.0.0.1/proxy/MY-WEBHOOK-IDENTIFIER with no content
No timeout when requesting on https://webhook.site/MY-WEBHOOK-IDENTIFIER with or without content

Actual behavior

Timeout when requesting on http://127.0.0.1/proxy/MY-WEBHOOK-IDENTIFIER with a content
No timeout when requesting on http://127.0.0.1/proxy/MY-WEBHOOK-IDENTIFIER with no content
No timeout when requesting on https://webhook.site/MY-WEBHOOK-IDENTIFIER with or without content

Setup

app.use("/proxy", createProxyMiddleware({ target: "https://webhook.site", pathRewrite: { ["^/proxy"]: "" }, logLevel: "debug", changeOrigin: true }));

  • http-proxy-middleware: 1.0.3
  • http-proxy-middleware configuration: logLevel=debug, changeOrigin=true, pathRewrite={ ["^/proxy"]: "" }
  • server: express + 4.16.3

client info

OS: Linux Mint 19.3 "Tricia"
User-Agent: PostmanRuntime/7.24.0

target server info

Webhook.site: A free web server to mirror incoming requests

@SoulKa
Copy link
Author

SoulKa commented Mar 27, 2020

It turned out that if I don not use the express.json middleware everything works!
app.use(express.json()); this line had to be deleted. I don't know if this is still a bug or just a bad combination of middleware i did.

Edit: By that this ticket is related to #320

sarumont added a commit to sarumont/http-proxy-middleware that referenced this issue Jul 30, 2020
Things like body-parser can break proxying anything with a body. This
checks for that (req.body will become an Object) and streams the body
into the proxy request.

Fixes chimurai#90, chimurai#320, chimurai#417 - and maybe some more
sarumont added a commit to sarumont/http-proxy-middleware that referenced this issue Jan 12, 2021
Things like body-parser can break proxying anything with a body. This
checks for that (req.body will become an Object) and streams the body
into the proxy request.

Fixes chimurai#90, chimurai#320, chimurai#417 - and maybe some more
@SoulKa
Copy link
Author

SoulKa commented Feb 1, 2021

I guess this fixes this issue :)

@SoulKa SoulKa closed this as completed Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant