5

I am having an issue getting content from my production Sanity Studio onto my production blog. I am using Next.js v13 and Sanity v3. The site is deployed on Vercel.

When I post from both my local Sanity Studio and production Sanity Studio, it updates on my local site. It doesn't update my production site unless I redeploy my site with Vercel. I have found what seems to be the solution for everyone else but me—add revalidate to getStaticProps. This does not work for me. Here is my code:

export async function getStaticProps(context) {
  const { slug = '' } = context.params;
  const post = await client.fetch(query, { slug });
  return {
    props: {
      post,
    },
    revalidate: 10,
  };
}

I am not getting any errors in the console or terminal on both the local and prod sites. Just for fun, I emptied the cache and did a hard reload on the prod page, opened it in an incognito window, opened it on Firefox, Chrome, and Edge, and have sat here for about an hour hitting refresh. Is there another solution?

techmeowt
  • 173
  • 1
  • 11

2 Answers2

1

You might want to try getServerSideProps

https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props


export async function getServerSideProps(context) {
  const { slug = '' } = context.params;
  const post = await client.fetch(query, { slug });
  return {
    props: {
      post
    }
  };
}
0

Try to create a webhook that triggers new builds when the content changes. I did that on a site hosted on Netlify, and it worked for me.

https://vercel.com/docs/concepts/deployments/deploy-hooks

https://www.sanity.io/blog/how-to-quickly-set-up-a-gatsby-js-jamstack-website-with-a-headless-cms#trigger-new-netlify-builds-on-content-changes-52f5edfa3342

t_coding
  • 53
  • 5