October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Express Webhook Signature Check: 4 Fixes After a Failing Deploy

Stripe webhook checks often fail after deployment because middleware parsed the body first. Check raw-body handling, the endpoint secret, server time and production configuration.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If a Stripe webhook signature check works locally but fails after you deploy an Express app, first check whether JSON middleware has changed the request body before verification. Stripe verifies the original, unmodified payload. Then check the signing secret, server clock and production endpoint configuration. The Stripe-specific code below is an example; if you use another webhook provider, follow its own signing instructions and header format.

1. Preserve the raw request body

Stripe signature verification needs the incoming request body in its original form. If express.json() runs first, it parses the payload into a JavaScript object; passing that parsed object to verification will not reproduce the original bytes. Stripe describes the requirement as the “raw, unmodified body” of the incoming request.

As an Amazon Associate I earn from qualifying purchases.

In Stripe’s Express example, the webhook route uses express.raw({ type: 'application/json' }), while other routes can continue using JSON parsing. Register the webhook route before any app-wide parser that would consume its request stream:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import express from 'express';
import Stripe from 'stripe';

const app = express();
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

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

  try {
    const event = stripe.webhooks.constructEvent(
      req.body,
      signature,
      process.env.STRIPE_WEBHOOK_SECRET
    );

    // Handle the verified event here.
    res.sendStatus(200);
  } catch (err) {
    res.status(400).send(`Webhook signature verification failed: ${err.message}`);
  }
});

app.use(express.json());

// Define other JSON-parsing routes below.

This follows the ordering in Stripe’s Express webhook signing example. Express also documents a JSON parser verify(req, res, buf, encoding) callback that provides the raw buffer if an application has a reason to capture it while parsing; see the Express API documentation. Do not stringify a parsed object and assume the result is byte-for-byte identical to what Stripe sent.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

2. Verify the signing secret belongs to this endpoint

A correct raw body can still fail verification when the signing secret is wrong. Check the value loaded by the deployed process, not just the value in your local environment, and confirm it belongs to the exact Stripe endpoint sending the event. A dashboard endpoint’s secret and the secret printed for a running Stripe CLI listener are not interchangeable.

In the Stripe Dashboard, compare the endpoint that receives the production event with the secret configured for that deployment. Stripe lists an incorrect endpoint signing secret among common causes of a signature mismatch in its webhook 4xx/5xx troubleshooting guidance. Keep secrets out of source control and logs.

Rank #2
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

3. Check timestamp-related failures and server time

If the error says the signature timestamp is outside the tolerance zone, verify that the production host has the correct date and time. Also make verification promptly after the request arrives: delayed processing can make a timestamp check fail even when the event body and secret are otherwise correct. Stripe identifies clock problems and delayed verification as possible causes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Compare the deployed endpoint and infrastructure

If the handler works locally but not in production, compare the deployed route and request path with the working local setup. Confirm the registered Stripe URL is the intended production URL, the endpoint is enabled, and it subscribes to the event types the application expects. Stripe’s Webhook Endpoints API reference documents endpoint configuration.

  • Check that the deployed Express route matches the registered URL path.
  • Compare middleware order and configuration between local and production.
  • Review application, web-server and hosting logs for route errors, parsing failures or recent configuration changes.
  • Check whether a server update or deployment changed how the request reaches the handler.

Stripe Support notes that new or changed code, a server update or a configuration change can introduce a new failure mode. A 4xx or 5xx response may therefore point to a deployment or routing issue as well as a signature mismatch.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep verification specific to the webhook provider

Validate a webhook signature before processing its event. GitHub, for example, explains that its delivery signature is generated from the webhook secret token and payload contents; its guidance is to validate webhook deliveries. That shared payload-and-secret principle does not make providers’ algorithms, headers or timestamp rules interchangeable. Use the provider’s official verification function, required body representation, signature header and secret source.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.94
SaleBestseller No. 2
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 5
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
These are the words in Charlotte's web, high in the barn; Their love has been shared by millions of readers
$6.13
Best Value
Sale
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
  • These are the words in Charlotte's web, high in the barn
  • Her spiderweb tells of her feelings for a little pig named Wilbur, as well as the feelings of a little girl named Fern … who loves Wilbur, too
  • Their love has been shared by millions of readers

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.