Closed ucharles closed 7 months ago
/[lng]/capsule/[id]
/[lng]/search
// ../capsule/[id]/page.tsx
import { cookies } from "next/headers";
export default async function Page({ params: { lng, id }, }: { params: { lng: string; id: string }; }) { const cookie = cookies(); const response = await fetch(API_URI + /api/capsules/${id}?lng=${lng}, { method: "GET", next: { revalidate: cacheTimeEnum.FIVE_MINUTES }, headers: { cookie: cookie, }, }); const data = await response.json(); }
/api/capsules/${id}?lng=${lng}
https://github.com/ucharles/gachatory/pull/94 에서 반영 완료
발단
/[lng]/capsule/[id]
혹은/[lng]/search
에서는 헤더 정보가 전송이 되지 않음문제
해결
import { cookies } from "next/headers";
export default async function Page({ params: { lng, id }, }: { params: { lng: string; id: string }; }) { const cookie = cookies(); const response = await fetch(API_URI +
/api/capsules/${id}?lng=${lng}
, { method: "GET", next: { revalidate: cacheTimeEnum.FIVE_MINUTES }, headers: { cookie: cookie, }, }); const data = await response.json(); }