핵심 원인 1: 서버 컴포넌트에서 params/searchParams를 바로 사용 → Next 15에선 Promise라 언랩 필요. 페이지 전환 시 경고/500 유발. 해결: 언랩(await/안전 언랩) 적용.

핵심 원인 2: 서버에서 상대경로로 fetch('/api/boards') 호출 → URL 파싱 실패. 해결: 요청 헤더(host, x-forwarded-proto)로 절대 URL 생성.
This commit is contained in:
koreacomp5
2025-10-10 14:46:59 +09:00
parent 744e4a80c9
commit f4959138d7

View File

@@ -1,11 +1,11 @@
import { PostList } from "@/app/components/PostList";
import { headers } from "next/headers";
import React, { use } from "react";
export default async function BoardDetail({ params, searchParams }: { params: Promise<{ id: string }>; searchParams: Promise<{ sort?: "recent" | "popular" }> }) {
const { id } = use(params);
const sp = use(searchParams);
const sort = sp?.sort ?? "recent";
export default async function BoardDetail({ params, searchParams }: { params: any; searchParams: any }) {
const p = params?.then ? await params : params;
const sp = searchParams?.then ? await searchParams : searchParams;
const id = p.id as string;
const sort = (sp?.sort as "recent" | "popular" | undefined) ?? "recent";
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
const h = await headers();
const host = h.get("host") ?? "localhost:3000";