Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cross origin (JSON based) XHR proxy requests are not forwarded properly. #697

Merged
merged 1 commit into from

2 participants

@brentlintner

The bodyParser middleware would parse the JSON properly, however the
form option in request was being used, and it was sent as a
'application/x-www-form-urlencoded' request. Instead it should be
stringified and set to the request's body option.

This fixes another issue pointed out in:

https://github.com/blackberry/Ripple-UI/issues/693

@brentlintner brentlintner Cross origin (JSON based) XHR proxy requests are not forwarded properly.
The bodyParser middleware would parse the JSON properly, however the
`form` option in `request` was being used, and it was sent as a
'application/x-www-form-urlencoded' request. Instead it should be
stringified and set to the `request`'s `body` option.

This fixes another issue pointed out in:

https://github.com/blackberry/Ripple-UI/issues/693
cd8a231
@brentlintner

@dansilivestru perhaps a second set of eyes? :-)

@brentlintner brentlintner merged commit cd8a231 into blackberry:next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 18, 2013
  1. @brentlintner

    Cross origin (JSON based) XHR proxy requests are not forwarded properly.

    brentlintner authored
    The bodyParser middleware would parse the JSON properly, however the
    `form` option in `request` was being used, and it was sent as a
    'application/x-www-form-urlencoded' request. Instead it should be
    stringified and set to the `request`'s `body` option.
    
    This fixes another issue pointed out in:
    
    https://github.com/blackberry/Ripple-UI/issues/693
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/server/proxy.js
View
6 lib/server/proxy.js
@@ -77,7 +77,11 @@ function proxy(req, res, callback) {
};
if (Object.keys(req.body).length > 0) {
- proxyReqData.form = req.body;
+ if (req.get("content-type") === "application/json") {
+ proxyReqData.body = JSON.stringify(req.body);
+ } else {
+ proxyReqData.form = req.body;
+ }
}
// Attempt to catch any sync errors
Something went wrong with that request. Please try again.