Skip to content

Commit 82c10f1

Browse files
update fetchcache to 'force-no-store'
1 parent 2c5d591 commit 82c10f1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

app/api/cron/route.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const fetchCache = 'force-no-store'
2+
13
import { publicURL } from '@/lib/utils';
24
import type { NextRequest } from 'next/server';
35

@@ -13,7 +15,10 @@ export function GET(request: NextRequest) {
1315
fetch(publicURL() + `/api/youtube/views`,
1416
{
1517
method: 'POST',
16-
headers: { authorization: `Bearer ${process.env.CRON_SECRET}` }
18+
headers: {
19+
authorization: `Bearer ${process.env.CRON_SECRET}`,
20+
'Cache-Control': 'no-cache'
21+
}
1722
});
1823

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

app/api/youtube/views/route.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const fetchCache = 'force-no-store'
2+
13
import { publicURL, youtubeParser } from '@/lib/utils';
24
import { createClient } from 'next-sanity';
35
import type { NextRequest } from 'next/server';
@@ -41,7 +43,7 @@ export async function POST(request: NextRequest) {
4143
}
4244

4345
// These should never match, if they do bail.
44-
if (!lastId && lastIdParam) {
46+
if (lastId === lastIdParam) {
4547
console.error('lastId matches current doc, stopping calls.');
4648
return new Response('lastId matches current doc, stopping calls.', { status: 200 });
4749
}
@@ -80,7 +82,10 @@ export async function POST(request: NextRequest) {
8082
fetch(publicURL() + `/api/youtube/views?lastId=${lastId}`,
8183
{
8284
method: 'POST',
83-
headers: { authorization: `Bearer ${process.env.CRON_SECRET}` }
85+
headers: {
86+
authorization: `Bearer ${process.env.CRON_SECRET}`,
87+
'Cache-Control': 'no-cache'
88+
}
8489
});
8590

8691
return Response.json(sanityUpdate);

0 commit comments

Comments
 (0)