핵심 원인 1: 서버 컴포넌트에서 params/searchParams를 바로 사용 → Next 15에선 Promise라 언랩 필요. 페이지 전환 시 경고/500 유발. 해결: 언랩(await/안전 언랩) 적용.
핵심 원인 2: 서버에서 상대경로로 fetch('/api/boards') 호출 → URL 파싱 실패. 해결: 요청 헤더(host, x-forwarded-proto)로 절대 URL 생성.
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import { PostList } from "@/app/components/PostList";
|
import { PostList } from "@/app/components/PostList";
|
||||||
import { headers } from "next/headers";
|
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" }> }) {
|
export default async function BoardDetail({ params, searchParams }: { params: any; searchParams: any }) {
|
||||||
const { id } = use(params);
|
const p = params?.then ? await params : params;
|
||||||
const sp = use(searchParams);
|
const sp = searchParams?.then ? await searchParams : searchParams;
|
||||||
const sort = sp?.sort ?? "recent";
|
const id = p.id as string;
|
||||||
|
const sort = (sp?.sort as "recent" | "popular" | undefined) ?? "recent";
|
||||||
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
|
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
|
||||||
const h = await headers();
|
const h = await headers();
|
||||||
const host = h.get("host") ?? "localhost:3000";
|
const host = h.get("host") ?? "localhost:3000";
|
||||||
|
|||||||
Reference in New Issue
Block a user