Ref not found. Ensure you have the correct ref and try again

Hi there,

I'm getting the following error when building my nextjs/prismic project and I want to know what it occurs and how I can resolve it. I know when I remove the project and clone it from my repo again the error won't occur anymore.

The error:
Creating an optimized production build ...q [Error]: Ref not found. Ensure you have the correct ref and try again. Master ref is: XXX.
url: 'https://dannyvanderwaal.cdn.prismic.io/api/v2/documents/search?q=......',
response: {
type: 'api_notfound_error',
message: 'Ref not found. Ensure you have the correct ref and try again. Master ref is: XXX'
}

Build error occurred
Error: Failed to collect page data for /[lang]/[uid]
at XXX/node_modules/next/dist/build/utils.js:1217:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}

Thank you in advance!

Kind regards,

Danny van der Waal

2 Likes

Hi Danny,

This sounds like the Next.js cache issue that we're dealing with in this latest version on Next.js, we're discussing this with their team:

I think the reason it works after you clone it again is because the .next is in your git ignore list and not uploaded to Github, so when you clone it and rerun it, the Next cache is newly generated again.

You can track the progress of this issue and other workarounds in the thread above.

Thanks.

1 Like

I also have the same error. The API reference was lost and is not allowing it to be deployed to Vercel.

Creating an optimized production build ...
14:44:40.386 ✓ Compiled successfully
14:44:40.387 Linting and checking validity of types ...
14:44:42.462 Collecting page data ...
14:44:44.080 Generating static pages (0/18) ...
14:44:44.959 F [Error]: Ref not found. Ensure you have the correct ref and try again. Master ref is: ZX0RABAAACAAEjjQ

3 Likes

I'm having this issue as well... trying to deploy my site with Netlify and getting the same error as above. is there a work around in the meantime?

Hi Team,

Can you try the workaround here: