Next.js Discord

Discord Forum

getStaticProps is not working

Unanswered
hmm_69 posted this in #help-forum
Open in Discord
I am trying Next js and following Docs but here data is not rendered in the home page
import Image from "next/image";

export async function getStaticProps() {
  const res = await fetch("http://localhost:3001/api/blogs", { mode: "cors" });
  const data = await res.json();

  return { props: { data } };
}

export default function Home({ data }) {
  return <main>{data}</main>;
}

The api endpoints is working fine

7 Replies

cors is allowed on all routes
I think the issue is I am using app router instead of page router
@hmm_69 I think the issue is I am using app router instead of page router
Correct; app router doesn’t have getStaticProps
@joulev Correct; app router doesn’t have getStaticProps
do u guys prefer app router over page ?
Yes I do
ok