Overview
In your nextjs server side, where you run your endpoint, you can queue a run and pass a webhook url to it.
Full Stack Demo
See how the callback works in a NextJS app
src/app/api/run/route.tsx
src/app/api/webhook/route.tsx
Enforcing Webhook Security
To enhance the security of your webhook endpoint, you can implement a secret token verification using thejose
library, which is compatible with edge environments. This method uses a shared secret to generate and verify signatures for each webhook request.
Here’s how to modify your code to include this security measure:
src/app/api/run/route.tsx
src/app/api/webhook/route.tsx