1

I am using ISR but adding new blogs, editing doesn't seem to be working on the production.

// /blogs/[slug].js

export async function getStaticProps({ params }) {
  const res = await api.get(`/api/v1/blogs/${params.slug}`);
  const blog = res.data;
  return { props: { blog }, revalidate: 60 };
}
export async function getStaticPaths() {
  const res = await api.get("/api/v1/blogs");
  const blogs = res.data;
  const paths = blogs.map((item) => ({
    params: { slug: item.slug },
  }));
  return { paths, fallback: false };
}
yathomasi
  • 458
  • 1
  • 6
  • 16

1 Answers1

2

You'll want to set your fallback value to either true or 'blocking' so that new pages can be generated. Otherwise, paths that don't exist at build time will simply 404.

export async function getStaticPaths() {
    // Existing code

    return { paths, fallback: true };
}
juliomalves
  • 42,130
  • 20
  • 150
  • 146