blob: 0d953a304fadc317d2143ee0a00484af4ab8bff9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import type { APIRoute } from 'astro';
import { purgeCache } from '@netlify/functions';
export const prerender = false;
export const POST: APIRoute = async ({ request }) => {
const { tags } = await request.json();
if (!Array.isArray(tags)) {
return new Response(`Bad Request: expected tags attribute with array of strings in the body, got ${typeof tags}`, { status: 400 });
}
await purgeCache({ tags });
return new Response(
JSON.stringify({
invalidated: tags
})
);
};
|