-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for optionally requesting, receiving, and validating webhooks #102
Conversation
return NextResponse.json({ detail: "Webhook received (but not validated)" }, { status: 200 }); | ||
} | ||
|
||
const webhookIsValid = await validateWebhook(request.clone(), secret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing this request.clone()
business here because you can only read the request body once in Next.js API routes. Without this change, you'll get TypeError: Body is unusable
when calling request.json()
after validation.
@mattt what do you think of this?
908d672
to
beba5b8
Compare
Update README.md Update README.md move the iguana Update README.md rearrange webhooks docs Update README.md
beba5b8
to
db584f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this looks quite reasonable to solve this issue! only nitpick, do I need ngrok for the production environment or just for dev servers? I don’t think the documentation makes it clear as is. but might be a me issue
Just for dev. Good shout. Updated in 863a91a |
Replaces #99 with an updated approach using Next.js app router with proper Request and Response objects.
Docs: https://github.com/replicate/getting-started-nextjs/tree/webhook-validation-on-app-router#webhooks
To Do
req
vsRequest
shenanigans go away?