Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
Ngrok error with stripe webhook: 400 bad request

So I have setup a stripe webhook with ngrok but for some reason when the webhook is triggered it shows this error in ngrok, but in stripe dashboard it shows that the webhook was successfull, but it doesn't do the stuff that it's supposed to do when it's successfull.

enter image description here

I have been trying to fix this problem for a week now but found no error in my code, ngrok or stripe so I am asking for help here.

here is my code for the webhook.

app.post('/webhook', express.raw({type: 'application/json'}), async (req, res) => {
    const sig = req.headers['stripe-signature']
    let event

    try {
        event = stripe.webhooks.constructEvent(req.body, sig, stripeWebhookSecret)
    } catch (err) {
        res.status(400).send(`Webhook Error: ${err.message}`)
        return
    }

    switch (event.type) {
        case 'checkout.session.completed':
            console.log('success')

            break
        default:
            console.log(`Unhandled event type ${event.type}`)
    }
    
    res.send()
})

here is how I expose my local server host to internet with ngrok

enter image description here

here is how I setup the webhook with stripe

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda