-
Notifications
You must be signed in to change notification settings - Fork 546
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(azure): raw body no longer returns parsed json #589
Conversation
Codecov Report
@@ Coverage Diff @@
## main #589 +/- ##
=======================================
Coverage 66.09% 66.09%
=======================================
Files 55 55
Lines 4109 4109
Branches 444 444
=======================================
Hits 2716 2716
Misses 1389 1389
Partials 4 4 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding! β€οΈ
@danielroe Hi! if yes, the same is happening in cloudflare deploys |
Co-authored-by: Daniel Roe <daniel@roe.dev>
π Linked issue
None
β Type of change
π Description
Azure functions with
httpTrigger
automatically JSON-parse the body. This is not explicitly mentioned in the docs (at least I couldn't find it), but in one of the examples they usereq.body.name
showing thatreq.body
is indeed an object. This then leads to problems when used with h3'suseRawBody
method, which actually returns the object instead of the stringy body when deployed to azure.This is fixed by using
req.rawBody
in the azure handler. It's hard to find documentation on this property, butrawBody
is used in an official test file:https://github.com/Azure/azure-functions-host/blob/71ecbb2c303214f96d7e17310681fd717180bdbb/test/WebJobs.Script.Tests.Integration/TestScripts/Node/HttpTrigger/index.js#L13
Example
console.log(req)
in the handler:π Checklist