From 919b56101651db67d6cda6fa34f374d4b48d98c5 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Tue, 23 Jan 2024 08:51:58 -0800 Subject: [PATCH] prevent cache on revalidation route --- app/api/revalidate/route.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/api/revalidate/route.tsx b/app/api/revalidate/route.tsx index 681ef7e7..8446ba9d 100644 --- a/app/api/revalidate/route.tsx +++ b/app/api/revalidate/route.tsx @@ -1,9 +1,13 @@ import {NextRequest, NextResponse} from "next/server"; import {revalidatePath, revalidateTag} from "next/cache"; +import {headers} from "next/headers"; // The app router doesn't correctly revalidate the paths on Vercel. This file is meant for testing and future // implementation when it actually works. export const GET = async (request: NextRequest) => { + // Call the headers to prevent the route from getting cached. + headers(); + const secret = request.nextUrl.searchParams.get('secret'); if (secret !== process.env.DRUPAL_REVALIDATE_SECRET) { return NextResponse.json({message: 'Invalid token'}, {status: 403});