Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Cross origin (JSON based) XHR proxy requests are not forwarded properly.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
brentlintner committed Jan 18, 2013
1 parent ecd637d commit cd8a231
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/server/proxy.js
Expand Up @@ -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
Expand Down

0 comments on commit cd8a231

Please sign in to comment.