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

Read body doesn't bring any result if ReverseProxy plug used inside Phoenix #3

Open
tjsousa opened this issue Nov 25, 2015 · 3 comments

Comments

@tjsousa
Copy link

tjsousa commented Nov 25, 2015

I have tinkered with integrating the ReverseProxy plug within a Phoenix app - using forward so that just a few selected endpoints would be proxied upstream.

However, I came across an issue where Plug's read_body/2 is being called earlier in the pipeline (inside Phoenix parsers), thus rendering the ReverseProxy call to read the body useless.

Any idea on a way to overcome this issue?

@baldmountain
Copy link

Spent a little time making this work in phoenix. read_body/2 has long since been called in phoenix. They key is to use body_params. Just call Poison.encode!(conn.body_params) rather than calling Conn.read_body(conn). (My actual change is to see if body_params exists and call Poison.encode!/1 if it does otherwise do the current code path using read_body/2.)

@slogsdon
Copy link
Owner

slogsdon commented Aug 3, 2017

@baldmountain Thanks for looking into this! If you're willing, be sure to submit a PR with your changes. I'd love for you to get credit here. If you're unable, I'll definitely be sure to attribute you with the solution.

@baldmountain
Copy link

@slogsdon sure, I can make a PR. I'll have to implement it properly since I just hacked things together to make it work for my case. :)

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

No branches or pull requests

3 participants