7.1 게시글 CRUD API 및 페이지 연동 o

This commit is contained in:
koreacomp5
2025-10-09 16:49:06 +09:00
parent f6dc33a42c
commit 7342c9bea2
7 changed files with 136 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
import { notFound } from "next/navigation";
export default async function PostDetail({ params }: { params: { id: string } }) {
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL ?? ""}/api/posts/${params.id}`, { cache: "no-store" });
if (!res.ok) return notFound();
const { post } = await res.json();
return (
<div>
<h1>{post.title}</h1>
<p style={{ whiteSpace: "pre-wrap" }}>{post.content}</p>
</div>
);
}