Webhook
In this part we will configure sanity webhook. Without enabling webhook you have to build your site everytime you create or update a blog post.
To configure webhook follow these steps below:
- Go to the API tab in your Sanity project and navigate to Webhooks
- Click the “Create webhook” button
- Set the Name & Description
- Set the URL to https://yoursite.com/api/webhook/sanity
- Choose Dataset to “production” or choose the one you prefer.
- Set the following options as shown below.
-
Trigger on: “Create”, “Update”, and “Delete”
-
Set Filter: _type == “post” (or your custom post type name)
-
Projection: Leave empty
-
Status: Keep it enabled
-
HTTP method: POST
-
HTTP Headers: Leave empty
-
Include drafts: No
-
Secret: Add random value and copy it.
-
Update the webhook env variable with the webhook secret.
SANITY_WEBHOOK_SECRET=YOUR_WEBHOOK_SECRET
Now, Save the configuration and create a webhook
Last updated on