Hi,
I'm migrating a website from NextJS pages router to the new app router. I only have one step remaining which is setting up the /revalidate endpoint.
I'm following this documentation and did as follow for my api endpoint.
// src/app/api/revalidate/route.ts
import { revalidateTag } from 'next/cache';
import { NextRequest, NextResponse } from 'next/server';
export async function POST(req: NextRequest) {
const { secret } = await req.json();
if (!secret || secret !== process.env.PRISMIC_WEBHOOK_SECRET) {
return NextResponse.json({ status: 401 });
}
revalidateTag('prismic')
return NextResponse.json({ revalidated: true, now: Date.now() });
}
However, when editing and saving my documents, or triggering the "test-trigger" from the dashboard, the request received by the endpoint is a GET instead of a POST.
AUG 14 20:52:54.47 405 www.pidsinee.com [GET] /api/revalidate
I tried deleting the webhook and creating it again, but I keep receiving GET instead of POST. I also checked on other projects and the "test-trigger" correctly sent a POST request to my endpoint.
To make sure the NextJS endpoint works, I used the following curl command:
curl --request POST \
--url https://pidsinee.com/api/revalidate \
--header 'Content-Type: application/json' \
--data '{
"secret": "SECRET_REDACTED"
}'
Url to the project is https://pidsinee-www.prismic.io
Cheers,