Repository navigation
[BUG] Proxy sends a JSON body even when Content-Type is application/x-www-form-urlencoded #15195
Unanswered
dmatviichuk
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Moved from #10557. That issue can no longer be opened now that issues are turned off for this repository.
Bug description
When a proxy request (
POST /v2/proxy) hasContent-Type: application/x-www-form-urlencoded, Hyperswitch still sendsrequest_bodyto the destination as JSON. Destination APIs that only accept form-encoded bodies reject the request.We hit this with Athena's
collectpaymentendpoint, which only accepts a form-url-encoded body.Expected behavior
The proxy reads the
Content-Typeheader of the proxy request. When it isapplication/x-www-form-urlencoded, it sendsrequest_bodyform-url-encoded:Actual behavior
execute_proxy_requestincrates/router/src/core/proxy.rsalways usesRequestContent::Json, so the body goes out as JSON whatever the header says:{ "billingzip": "85000", "expirationyearyyyy": "2030", "amount": "20.00" }Steps to reproduce
Send a proxy request like this:
{ "destination_url": "https://api.preview.platform.example.com/v1/1/user/1/collectpayment", "headers": { "Authorization": "Bearer <token>", "Content-Type": "application/x-www-form-urlencoded" }, "method": "POST", "request_body": { "billingzip": "85000", "expirationyearyyyy": "2030", "amount": "20.00" } }The outgoing HTTP request body is JSON, not form-encoded.
Environment
Self-hosted v2 build (
VERSION_FEATURE_SET v2). We first saw this on v1.117.0, andmainstill does it.Fix
PR #15197
All reactions