Skip to content

Commit

Permalink
fix: use revalidatePath
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldElysium committed Mar 13, 2024
1 parent a5e6261 commit 0fbb8cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
19 changes: 19 additions & 0 deletions src/app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from 'next/server';
import { revalidatePath } from 'next/cache';

// eslint-disable-next-line import/prefer-default-export
export async function POST(req: NextRequest) {
if (req.headers.get('Authorization') !== process.env.REVALIDATE_SECRET) {
return new NextResponse(undefined, { status: 401 });
}

const body = await req.json();

if (!body.path) {
return new NextResponse(undefined, { status: 400 });
}

revalidatePath(body.path, 'layout');

return new NextResponse();
}
11 changes: 0 additions & 11 deletions src/pages/api/revalidate.ts

This file was deleted.

0 comments on commit 0fbb8cb

Please sign in to comment.