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

fix: properly proxy the body #460

Closed
wants to merge 2 commits into from
Closed

Conversation

sarumont
Copy link

@sarumont sarumont commented 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 #90, #320, #417 - and maybe some more

@coveralls
Copy link

coveralls commented Jul 30, 2020

Coverage Status

Coverage decreased (-0.9%) to 87.421% when pulling 691f399 on sarumont:master into 7ae82e8 on chimurai:master.

@chimurai
Copy link
Owner

chimurai commented Aug 3, 2020

Thanks for the PR.

Could you add a test as proof for this fix?

You can add body-parser to the devDependencies if needed for the test.

@ghost
Copy link

ghost commented Jan 12, 2021

DeepCode's analysis on #691f39 found:

  • ⚠️ 1 warning 👇

Top issues

Description Example fixes
The Content-Length header should be set by the browser, not in code (in setHeader). Occurrences: 🔧 Example fixes

👉 View analysis in DeepCode’s Dashboard | Configure the bot

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
It is possible that the content length is not equivalent due to JSON
serialization, so we need to re-write the Content-Length header to the
upstream.

This commit also restricts the fix to ONLY handle JSON. Other content
types could be handled with some conditionals if necessary.
@sarumont
Copy link
Author

@chimurai Sorry, lost track of this PR between work and a new baby arriving. :) I just updated with a fix for a bug I found, and I'll drop a test in as soon as I can!

@chimurai
Copy link
Owner

fixed in #492

@chimurai chimurai closed this Apr 24, 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 this pull request may close these issues.

Modifying the POST body in onProxyReq
3 participants