Problem implementing on demand revalidation (Next 13.4.12)
Unanswered
Satin Angora posted this in #help-forum
Satin AngoraOP
Hey there,
I'm working on a project using Next.js 13 along with an app directory and Sanity v3 CMS. So, I tried to set up on-demand revalidation using the Sanity Webhook. The thing is, my API endpoint gives me a success message and the revalidatePath function seems to run as expected. But the page doesn't actually get revalidated.
I skipped the webhook to pinpoint the problem; my current endpoint looks like this.
The endpoint returns the correct path. I've tried revalidating "my-path", "/my-path" and "/my-path/page".
I tried using cache tag and revalidateTag, but no dice – got the same results.
Testing process:
Deployed to test environment, published changes in Sanity CMS and manually triggered mypage.com/api/revalidate?path=my-path
which returns:
App directory structure:
All help would be greatly appreciated.
I'm working on a project using Next.js 13 along with an app directory and Sanity v3 CMS. So, I tried to set up on-demand revalidation using the Sanity Webhook. The thing is, my API endpoint gives me a success message and the revalidatePath function seems to run as expected. But the page doesn't actually get revalidated.
I skipped the webhook to pinpoint the problem; my current endpoint looks like this.
export async function POST(request: NextRequest) {
const path = request.nextUrl.searchParams.get("path") ?? "/";
revalidatePath(path);
return NextResponse.json({
message:Successfully revalidated route: ${path},
revalidated: true,
now: Date.now(),
});
}The endpoint returns the correct path. I've tried revalidating "my-path", "/my-path" and "/my-path/page".
I tried using cache tag and revalidateTag, but no dice – got the same results.
Testing process:
Deployed to test environment, published changes in Sanity CMS and manually triggered mypage.com/api/revalidate?path=my-path
which returns:
{"message":"Successfully revalidated path: my-path","revalidated":true,"now":1691653561596}App directory structure:
app
(app)
(myRouteGroup)
my-path
page.tsx
layout.tsx
not-found.tsx
(myRouteGroupTwo)
page.tsx
layout.tsx
not-found.tsx
(studio)All help would be greatly appreciated.