Home > Back-end >  Cloudflare with Stripe webhook returns HTTP 301 error
Cloudflare with Stripe webhook returns HTTP 301 error

Time:10-28

I am running a NodeJS server on DigitalOcean that is listening for Stripe webhooks on the route /stripe-webhook with NGINX as a reverse proxy. It works perfectly during testing with the Stripe CLI on my local machine. However when I deploy to the server the Stripe dashboard always shows a HTTP 301 error code when it sends an event to the domain.

The domain is hosted on Cloudlfare which provides https. In the Stripe dashboard it is configured to send the webhook to https://example.com/stripe-webhook so I am not too sure why it is showing a redirect error? When I send a manual POST request to the same URL it works fine and does not return any redirect header.

Any help would be greatly appreciated. Cheers

CodePudding user response:

Here is my error: my Stripe dashboard was sending webhooks to:

https://example.com/stripe-webook

But my NGINX configuration was listening on :

https://example.com/stripe-webhook/

It was redirecting to add that extra slash on and since Stripe has a 0 redirects policy with webhooks it was throwing an error.

  • Related