#RGRTHAT-webhook

1 messages · Page 1 of 1 (latest)

vernal python
#

Hello! Can you give me some more context here?

dapper fiber
#
// needs raw body!
const webhook_route = require("./routes/webhook");
//

app.use(webhook_route, express.raw({ type: "*/*" }));
app.use(express.json());

// my other routes
let other_route = require("./routes/other_route")
app.use(other_route)
#

@vernal python Webhooks need raw body

#

but all my other routes need json parsing

#

so I need to somehow conditionally use the json parsing middleware, and the express.raw

#

but its not working

vernal python
#

Is there a reason you're doing
app.use(webhook_route, express.raw({ type: "*/*" }));
instead of just
app.use('/webhook', express.raw({ type: "*/*" })); (not sure if "/webhook" is what your route is or it's something else, but you shouldn't be passing in the export into app.use)

dapper fiber
#

when u pass the export, u pass all the routes in that file

vernal python
#

As far as I know, app.use() takes in a path/string for that first argument - not an export. Have you tried it with just the path?

dapper fiber
#

IT WORKS

#

I suppose that when u want to target individual routes, then u have to specify path/string

#

or its, if u have 2 arguments, then first is path, and second is middleware

#

if u have 1 argument, then its ether route, or a router object