Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
404 on new posts, after build-time, using Next.js and Sanity.io

My goal is to be able to add new posts the CMS(Sanity.io) after build-time, and for the site to be able to display received data on a provided slug using dynamic routes.

Everything works well in dev environment, but in production it seems the page can't use the new slugs provided from the CMS, and responds with a 404.

Here's my code getting the posts from the CMS, inside my [slug].tsx file.

[slug.tsx]

export const getStaticPaths: GetStaticPaths = async () => {
  const query = `
  *[_type=='post']{
    _id,
    slug {
      current
    }
  }`

  const posts = await sanityClient.fetch(query)

  const paths = posts.map((post: Post) => ({
    params: {
      slug: post.slug.current,
    },
  }))

  return {
    paths,
    fallback: 'blocking',
  }
}

export const getStaticProps: GetStaticProps = async ({ params }) => {
  const query = `
  *[_type=='post' && slug.current == $slug][0]{
    _id,
    publishedAt,
    title,
    description,
    mainImage,
    gallery[0]->{
      title,
      link,
      images,
      display,
    },
    slug,
    body
  }`
  const post = await sanityClient.fetch(query, { slug: params?.slug })

  return {
    props: {
      post,
    },
    revalidate: 10,
  }
}

When I add new posts in the CMS I immediately see the thumbnail come up on the website, with the correct image and other data, but when I click the thumbnail I get 404.

I hope someone can help me!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda