title: Stripe Webhook constructEvent method is returning 400 error when pointed to ec2 instance
body: <p>I have developed my application in windows OS and integrated Stripe webhook with the help of ngrok. Everything was smooth and I was able to receive the events from webhook. but once I moved it to ec2 instance on AWS Cloud, it is throwing me an error.</p>
  <p>Error: (In Stripe Dashboard Webhook Attempts Section)</p>
  <blockquote>
  <p>Webhook Error: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined</p>
  </blockquote>
  <p>It is strange that have not changed any piece of code and it still works on windows.</p>
  <p>Complete Error:</p>
  <pre><code>TypeError [ERR_INVALID_ARG_TYPE]: The &quot;key&quot; argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject
  . Received undefined
      at prepareSecretKey (internal/crypto/keys.js:322:11)
      at new Hmac (internal/crypto/hash.js:111:9)
      at Object.createHmac (crypto.js:147:10)
      at Object._computeSignature (/home/psuser/middleware/node_modules/stripe/lib/Webhooks.js:65:8)
      at Object.verifyHeader (/home/psuser/middleware/node_modules/stripe/lib/Webhooks.js:107:36)
      at Object.constructEvent (/home/psuser/middleware/node_modules/stripe/lib/Webhooks.js:12:20)
      at /home/psuser/middleware/routes/carts.js:210:29
      at Layer.handle [as handle_request] (/home/psuser/middleware/node_modules/express/lib/router/layer.js:95:5)
      at next (/home/psuser/middleware/node_modules/express/lib/router/route.js:137:13)
      at /home/psuser/middleware/node_modules/body-parser/lib/read.js:130:5
      at invokeCallback (/home/psuser/middleware/node_modules/raw-body/index.js:224:16)
      at done (/home/psuser/middleware/node_modules/raw-body/index.js:213:7)
      at IncomingMessage.onEnd (/home/psuser/middleware/node_modules/raw-body/index.js:273:7)
      at IncomingMessage.emit (events.js:327:22)
      at endReadableNT (_stream_readable.js:1327:12)
      at processTicksAndRejections (internal/process/task_queues.js:80:21) {
    code: 'ERR_INVALID_ARG_TYPE'
  }
  The &quot;key&quot; argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received undefined
  
  // End point Code
  
  
  router.post('/webhook', async (request, response) =&gt; {
    const sig = request.headers['stripe-signature'];
    let event;
  
    try {
      event = stripe.webhooks.constructEvent(request.rawBody, sig, process.env.STRIPE_WEBHOOK_SECRET);
    }
    catch (err) {
      console.log(err.message);
      return response.status(400).send(`Webhook Error: ${err.message}`);
    }
  });
  
  // In app.js 
  
  
  app.use(express.json({
    // Because Stripe needs the raw body, we compute it but only when hitting the Stripe callback URL.
    verify: function (req, res, buf) {
      var url = req.originalUrl;
      if (url.endsWith('/webhook')) {
        req.rawBody = buf.toString()
      }
    }
  }));
  </code></pre>