Skip to content

Commit d2e0315

Browse files
committed
fix(api): resolve stats cache header typing
1 parent 9a8ed21 commit d2e0315

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

app/api/stats/route.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ export async function GET(request: Request) {
5050
const userData = await fetchGitHubContributions(user, { bypassCache: refresh });
5151
const calendar = userData.calendar;
5252
const stats = calculateStreak(calendar, timezone);
53-
const headers = refresh
54-
? {
55-
'Cache-Control': 'no-store, no-cache, must-revalidate',
56-
Pragma: 'no-cache',
57-
Expires: '0',
58-
}
59-
: {
60-
// Cache until next UTC midnight; clients can bust with ?refresh=true
61-
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400',
62-
};
53+
const headers = new Headers({
54+
// Cache until next UTC midnight; clients can bust with ?refresh=true
55+
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400',
56+
});
57+
58+
if (refresh) {
59+
headers.set('Cache-Control', 'no-store, no-cache, must-revalidate');
60+
headers.set('Pragma', 'no-cache');
61+
headers.set('Expires', '0');
62+
}
6363

6464
return NextResponse.json(
6565
{

0 commit comments

Comments
 (0)