Property req.rawBody is missing
See original GitHub issueRelated issues
[REQUIRED] Version info
node:
v11.6.0
firebase-functions:
2.2.0
firebase-tools:
6.4.0
firebase-admin:
7.0.0
[REQUIRED] Test case
export const stripeWebhook = functions.https.onRequest((req, res) => {
const rawBody = req.rawBody;
}
[REQUIRED] Steps to reproduce
Implement a http request handler function. Try to use req.rawBody.
[REQUIRED] Expected behavior
I expect req.rawBody to exist, just like it is mentioned in the documentation (https://firebase.google.com/docs/functions/http-events).
[REQUIRED] Actual behavior
Were you able to successfully deploy your functions?
I’m not able to deploy, because type Request ist missing property rawBody
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Express missing properties when using typescript: rawBody
My temporary fix is to use the as keyword to tell the compiler to consider the req object as another type when you...
Read more >raw-body - npm
Gets the entire buffer of a stream either as a Buffer or a string. Validates the stream's length against an expected length and...
Read more >Create dynamic responses with templating request helpers
The full request's raw body can also be fetched when the path is omitted ( {{body}} ) independently ... 1, string, Default value...
Read more >Request - Fastify
Request is a core Fastify object containing the following fields: ... performance reason on not found route, you may see that we will...
Read more >Controllers | Ts.ED - A Node.js and TypeScript Framework on ...
Raw Body v6.20.0+. RawBodyParams decorator provides you quick access to the request.rawBody : import ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FYI, it looks like if you use
functions.https.Request
rawBody passes the TS compiler. However, if you use the aliasfunctions.Request
, the compiler does not find rawBodyThis answer here fixed it for me (it’s @mitchellbutler’s mention of this issue on Apr 21 2020, just a few comments up from here): https://github.com/stripe/stripe-node/issues/341#issuecomment-617193575
The main line being:
const firebaseRequest = req as https.Request
which types it asfunctions.https.Request
, enabling access torawBody
. Also reference @deremer’s comment above: https://github.com/firebase/firebase-functions/issues/417#issuecomment-500657318