Reputation: 1032
I am using Vercel to deploy a Next.js app. This app contains backend code that listens for events from third-party services via webhooks, such as the user creation event from Clerk.
To do this, I need to configure the webhook endpoint on these third-party services to specify where I want the events to be sent.
Vercel offers a service named Previews, which generates preview builds every time a new commit is pushed to a remote branch configured with Vercel. I would like the webhooks to function with these preview builds, even though these builds generate random URLs.
Is there a way for these preview apps to still receive webhooks?
Upvotes: 6
Views: 1216
Reputation: 1535
I don't know the timing on when this became available, but as of now (Feb 2025), there's a setting, Settings
-> Deployment Protection
-> Protection Bypass for Automation
, which sets a System Environment Variable. You need to set a 32-character token here, which you can then put in the headers of your web-hook request as x-vercel-protection-bypass
.
As of this moment, this is available in the hobby (free) plan, and is working for me.
Upvotes: 1
Reputation: 1
If I understood you correctly, you want to use a preview build to test your webhooks?
You could set a domain for your preview builds inside the domain settings of your project. But I think for this to work, you would also need to disable the deployment protection on the project. (Settings -> Deployment Protection)
Upvotes: 0
Reputation: 1283
My temporary testing method is to switch off "Vercel Authentication" in the deployment protection settings on the project. It's not a permanent solution, however, it means that I can test my e2e flow and once the webhooks are tested I can switch it back on.
I believe the Vercel-recommended solution is their "Deployment Protection Exceptions", starting at $150 p/m, likely aimed at businesses.
There is an open question in their help section on GitHub: https://github.com/orgs/vercel/discussions/7007
Upvotes: 0