From 3a1a8223eafb5547bac389109f1e03d89bb0b147 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 26 Sep 2022 16:52:07 -0700 Subject: [PATCH 1/2] Revert "Fix: Contentful webhook body parse. (#40732)" This reverts commit ef9ba4509a0dfc7b43df3f0f5bbedf78d6de8327. --- examples/cms-contentful/pages/api/revalidate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cms-contentful/pages/api/revalidate.js b/examples/cms-contentful/pages/api/revalidate.js index a4cf828e518fa..8b3b73924f1ec 100644 --- a/examples/cms-contentful/pages/api/revalidate.js +++ b/examples/cms-contentful/pages/api/revalidate.js @@ -14,7 +14,7 @@ export default async function handler(req, res) { } try { - let postSlug = JSON.parse(req.body).fields.slug['en-US'] + let postSlug = req.body.fields.slug['en-US'] // revalidate the individual post and the home page await res.revalidate(`/posts/${postSlug}`) From a2c340e7b078878fd577dfe2fbfa2c1afc196c5d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 26 Sep 2022 16:54:56 -0700 Subject: [PATCH 2/2] add note to readme --- examples/cms-contentful/pages/api/revalidate.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/cms-contentful/pages/api/revalidate.js b/examples/cms-contentful/pages/api/revalidate.js index 8b3b73924f1ec..fd5a7078d37f8 100644 --- a/examples/cms-contentful/pages/api/revalidate.js +++ b/examples/cms-contentful/pages/api/revalidate.js @@ -14,6 +14,8 @@ export default async function handler(req, res) { } try { + // Note: if this fails to parse you may have forget to set the + // "content-type" header correctly as mentioned here https://github.com/vercel/next.js/blob/canary/examples/cms-contentful/README.md#step-9-try-using-on-demand-revalidation let postSlug = req.body.fields.slug['en-US'] // revalidate the individual post and the home page