"Prismic repository not found" when deploying in Vercel using private API

Hi Team, I run into error of "NotFoundError: Prismic repository not found." when deploying in Vercel using private API. This is working fine in my local & I have tested that my access token has been passed correctly.
Can I get some help on this? Thank you

1 Like

Hi @tanacitygroup,

We rolled out a change to the API last week so that an incorrect ref will also return a 404: Not Found error. We're going to release a patch to @prismicio/client soon to improve the error messaging in the client. That being the case, it's possible that this error is in fact due to an incorrect ref. Can you think of a reason why the ref might be wrong? Does the error occur in a preview session? Are you using @prismicio/client?

Sam

1 Like

I am also getting this error today, although my repo is currently public. The response from the request is:

{
  "type": "api_notfound_error",
  "message": "Ref not found. Ensure you have the correct ref and try again. Master ref is: SomeDifferentRef"
}

I haven't deployed this project to Vercel yet. I am seeing this locally when I create a production build when it's doing the pre-rendering.

The production build was working fine a couple days ago and dev builds are still currently working correctly.

If I manually change the ref to the master ref in the response, the production build succeeds.

Any ideas?

Hey @travis.travis,

Thanks for sharing your error.

If I manually change the ref to the master ref

How are you doing this? Can you share the relevant code snippet, both with and without the manual ref?

Sam

Hi @samlittlefair ,
Dumb question, how do I check the ref that I'm using? But I'm expecting to use the same ref (master) for both local & deployment. I run into this error when generating static site in Vercel, whilst it was working ok in my local environment.

Does the error occur in a preview session? No, this occur when generating static sites

Are you using @prismicio/client ? Yes, here's the versions:
"@prismicio/client": "7.2.0",
"@prismicio/next": "1.3.5",
"@prismicio/react": "2.7.3",

In my case, when Im changing to public API, the deployment works

All I mean by "manually changed the ref" is that I added it in the call to createClient in my prismicio.ts file:

export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
  const client = prismic.createClient(repositoryName, {
    ref: "myMasterRef",
    routes,
    fetchOptions:
      process.env.NODE_ENV === "production"
        ? { next: { tags: ["prismic"] }, cache: "force-cache" }
        : { next: { revalidate: 5 } },
    ...config,
  });

  return client;
};

The error happens when I exclude the ref property and let prismic do whatever it does automatically:

export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
  const client = prismic.createClient(repositoryName, {
    routes,
    fetchOptions:
      process.env.NODE_ENV === "production"
        ? { next: { tags: ["prismic"] }, cache: "force-cache" }
        : { next: { revalidate: 5 } },
    ...config,
  });

  return client;
};

Also, an interesting twist is that I've now deployed to Vercel and it is working fine there.

I only see a problem if I run yarn build locally, so it's not a major problem, but it is rather odd.

1 Like

Hi @tanacitygroup and @travis.travis,

We're looking into issues with caching in Next.js. Are you both using the App Router? If so, you can take a look at this thread to see if there's any helpful information:

Sam

Hey @tanacitygroup and @travis.travis,

We've opened an issue on the Next.js GitHub repository. Feel free to upvote and subscribe to follow along:

Sam

Thanks Sam, at the moment I stopped using cache

1 Like