Skip to content

Commit

Permalink
feat: add revalidate routes for home and job pages
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnrivers committed Dec 16, 2024
1 parent 61662a4 commit 308b127
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 52 deletions.
27 changes: 27 additions & 0 deletions src/app/api/revalidate/home/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { revalidatePath } from 'next/cache';
import { headers } from 'next/headers';

export async function POST() {
const headersList = await headers();
const secret = headersList.get('X-Secret');

if (secret !== process.env.REVALIDATE_API_SECRET) {
return Response.json(
{
revalidated: false,
message: 'Invalid token',
},
{ status: 401 },
);
}

revalidatePath('/');

return Response.json(
{
revalidated: true,
message: 'Revalidated /',
},
{ status: 200 },
);
}
27 changes: 27 additions & 0 deletions src/app/api/revalidate/job/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { revalidatePath } from 'next/cache';
import { headers } from 'next/headers';

export async function POST() {
const headersList = await headers();
const secret = headersList.get('X-Secret');

if (secret !== process.env.REVALIDATE_API_SECRET) {
return Response.json(
{
revalidated: false,
message: 'Invalid token',
},
{ status: 401 },
);
}

revalidatePath('/job');

return Response.json(
{
revalidated: true,
message: 'Revalidated /job',
},
{ status: 200 },
);
}
File renamed without changes.
52 changes: 0 additions & 52 deletions src/app/api/revalidate/route.ts

This file was deleted.

0 comments on commit 308b127

Please sign in to comment.