Issues with continues deployment in Netflify

So I am working on moving a nextjs site to prismic, and I have setup a test server in netlify, I have created the build hook in netlify and saved it in the webhook in prismic settings. Whenever I make a change in the site I can see that the webhook in prismic is triggered with a 200 status code and a build is started in netlify. However once the build is finished and I reload the page, changes are not displayed. I tried clearing cache and opening in incognito and nothing changes, I can only see the new changes if I manually build the site again with the "clear cache and retry with latest commit" button.

Screenshot 2023-11-30 180328

I am using a secret and custom tag

and here is my api/revalidate/route.js

import { NextResponse } from "next/server";
import { revalidateTag } from "next/cache"; 

export async function POST(request) {
  const { secret } = await request.json();
  const tag = request.headers.get('tag');

  if (secret !== process.env.REVALIDATION_TOKEN) {
    return NextResponse.json({ message: 'Invalid secret' }, { status: 401 })
  }

  if (!tag) {
    return NextResponse.json(
      { message: "Missing tag header" },
      { status: 400 }
    )
  }

  revalidateTag(tag);

  return NextResponse.json(
    { revalidated: true, now: Date.now() },
    { status: 200 }
  );
}

And I have also included the env var in netlify

any help would be appreciated.

Hi @alvarocorpeno10,

Many users have reported issues with content not updating on Next.js sites. We've been investigating, and we suspect it might be a problem with caching in Next 13 and 14. We've opened an issue on the Next GitHub repository, and it seems like Next has made some moves to address the problem — though it seems like it hasn't gone away entirely.

You can read through the thread here to see if any of these troubleshooting tips might be helpful. You can also check out the linked GitHub issue to upvote and subscribe to updates.

Sam

Thanks, it seem the access token did it, still have some caching issues but nothing mayor, thanks for the help.
For anyone else that stumbles on this issue add an access token in prismic settings

Add it to the environment variables in netlify site configuration:

And then modify prismicio.js to use the access token:

this solved the issue for me.

1 Like