Access raw body of Stripe webhook in Nest.js

后端 未结 4 1673
抹茶落季
抹茶落季 2021-02-03 11:36

I need to access the raw body of the webhook request from Stripe in my Nest.js application.

Following this example, I added the below to the module which has a controlle

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 12:24

    Today,

    as I am using NestJS and Stripe

    I installed body-parser (npm), then in the main.ts, just add

     app.use('/payment/hooks', bodyParser.raw({type: 'application/json'}));
    

    and it will be restricted to this route ! no overload

提交回复
热议问题