Skip to content

Commit 2c5d591

Browse files
change youtube to POST no caching
1 parent 0124c86 commit 2c5d591

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/api/cron/route.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export function GET(request: NextRequest) {
1111
// Don't await just trigger
1212
console.log('youtube views triggered');
1313
fetch(publicURL() + `/api/youtube/views`,
14-
{ headers: { authorization: `Bearer ${process.env.CRON_SECRET}` } });
14+
{
15+
method: 'POST',
16+
headers: { authorization: `Bearer ${process.env.CRON_SECRET}` }
17+
});
1518

1619
return Response.json({ success: true });
1720
}

app/api/youtube/views/route.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const sanityWriteClient = createClient({
1111
useCdn: false
1212
});
1313

14-
export async function GET(request: NextRequest) {
14+
export async function POST(request: NextRequest) {
1515
const authHeader = request.headers.get('authorization');
1616
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
1717
return new Response('Unauthorized', {
@@ -78,7 +78,10 @@ export async function GET(request: NextRequest) {
7878

7979
// Trigger next call, don't wait for response
8080
fetch(publicURL() + `/api/youtube/views?lastId=${lastId}`,
81-
{ headers: { authorization: `Bearer ${process.env.CRON_SECRET}` } });
81+
{
82+
method: 'POST',
83+
headers: { authorization: `Bearer ${process.env.CRON_SECRET}` }
84+
});
8285

8386
return Response.json(sanityUpdate);
8487
} catch (error) {

0 commit comments

Comments
 (0)