export const revalidate = 0
async function getPosts(): Promise<Post[]>{
const data = await fetch("http://localhost:3000/api/get-posts")
return data.json()
}
export default async function Page() {
const posts = await getPosts()
console.log(posts)
return (
<div>
<h1 className="text-slate-600">Hello, NextJS, Typescript and Prisma!</h1>
<div className="grid grid-cols-4 gap-4 py-4">
{posts.map(post => (
<PostComponent postData={post} key={post.id} />
))}
</div>
</div>
)
}
Dev works fine but if I try to build it or deploy it I get this error:
Application error: a client-side exception has occurred (see the browser console for more information).
If I remove revalidate option it also works fine but doesn't fetch after build and only uses cache