There's one part that was on me. The preview endpoint in the Prismic dashboard wasn't set up correctly for NextJS. I fixed that to point to /api/preivew--so it wasn't sending the token in the first place.
However, now that it's hitting the preview endpoint it breaks completely:
Ok, I figured out why it isn't working and it seems to be fixed now. I'll describe the fix so others can hopefully get past this if they're starting fresh.
Basically, there are some errors in the Next.js "setup" documentation when it comes to the prismicio.js file.
On the setup page (Set up Prismic with Next.js - Prismic) the documentation asks you to create the file and create the following createClient() function:
// This factory function allows smooth preview setup
export function createClient(config) {
const client = prismic.createClient(endpoint, {
...config,
})
enableAutoPreviews({
client,
context: config.context,
req: config.req,
})
return client
}
The problem it's missing "previewData" in the "enableAutoPreviews" section (it's also missing some optional chain operators which caused a different bug for me when setting up dynamic pages). The correct version is:
I am glad that the issue has been solved. Thank you so much for sharing feedback and working code snippets. I'll share with the team and make the necessary changes.