perf: stats/performance 인증 제거 + CDN 캐시 10분 적용
- Supabase auth 왕복 1-2s 제거 (집계 데이터는 인증 불필요) - Cache-Control: s-maxage=600 으로 Vercel Edge CDN 캐싱 적용 - 동일 요청 10분간 NAS 호출 없이 CDN에서 즉시 응답 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { createClient } from '@/lib/supabase/server';
|
|
||||||
import { nasGet, handleNasError } from '../../_nas';
|
import { nasGet, handleNasError } from '../../_nas';
|
||||||
|
|
||||||
|
// 공개 집계 데이터 — 인증 불필요, Vercel CDN에서 10분 캐시
|
||||||
export const maxDuration = 60;
|
export const maxDuration = 60;
|
||||||
|
export const revalidate = 600; // 10분
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
const supabase = await createClient();
|
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
|
||||||
if (!user) return NextResponse.json({ error: 'UNAUTHORIZED' }, { status: 401 });
|
|
||||||
const data = await nasGet('/api/lotto/stats/performance');
|
const data = await nasGet('/api/lotto/stats/performance');
|
||||||
return NextResponse.json(data);
|
const res = NextResponse.json(data);
|
||||||
|
res.headers.set('Cache-Control', 's-maxage=600, stale-while-revalidate=60');
|
||||||
|
return res;
|
||||||
} catch (err) { return handleNasError(err); }
|
} catch (err) { return handleNasError(err); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user