I’m implementing Lemon Squeezy webhooks in my Next.js application deployed on Vercel. When a webhook is triggered, my endpoint needs to fetch price data from the Lemon Squeezy API. Here’s the exact flow:
A Lemon Squeezy webhook calls my route endpoint
This endpoint calls a function updateSubscription
Inside updateSubscription, there’s a call to getSubscriptionPrice which fetches price data from https://api.lemonsqueezy.com/v1/prices/{price_id}
The issue is that this API call silently fails in the Vercel production environment, but works perfectly in my local development environment. To debug this:
I verified that my fetch implementation works by successfully calling other APIs (like JSONPlaceholder) from the same Vercel function
I confirmed that the API key is correctly set in Vercel’s environment variables
The exact same code works when running locally
The request doesn’t return any error - it simply stops executing after attempting to fetch from the Lemon Squeezy API. This suggests there might be some IP-based blocking or networking issue between Vercel’s serverless functions. Can someone help?
Sorry that you’re facing this issue. Also, so nice that you shared the debugging details.
You said you tried JSONPlaceholder API in the prod which worked. Did you try any other endpoint from lemonsqueezy on production?
Have you confirmed that you are using the live environment credentials for calling the live/production API? (it’s easy to mix these, i’ve been guilty of it in the past)
At last, can you share the Vercel logs for such a webhook request?
I’ve realized that the lemonsqueezy documentation had a mistake. I was not waiting one of my async functions in the route handler so the route handler was stopping the process while my function not completed yet.