I was hoping someone could help me with an issue I'm having getting Prismic Previews to work. I've scoured this forum for a solution but unfortunately I wasn't able to find any that worked for me.
I am developing on Nuxt/Netlify for a client and am trying to set up Prismic Previews for them. I've left the Link resolver to "/preview" and I've installed the @nuxtjs/prismic package into my repository.
I have 2 Prismic repositories, one for development and the other is for the client. Both configurations are the same, bar the content (we still use the same content types). On our development repository, previewing content works fine; I am able to see the content I have not yet published to the document. However, on the client repository, with the same setup, whenever I click on the Preview button, page will load fine except the content does not show any of the changes I've made.
Could someone help me out? Happy to provide more information if required.
Hello @sog, if you're using environments, you must remember that these work as separated entities. Even if they share the same Custom Types and content, they are two different entities. If you have configured your project to set up previews only for the first one, you need to test with the second repository URL and add a new Link resolver for it, for example: /preview-staging
I am not using Prismic Environments, I am using the same code repository for both Prismic repositories. When I set up the Previews on both, I make sure that the link resolver is the same. In fact, on my staging site, I can get the toolbar to appear and I can check the cookie which when I query it, will return the updated document, however, on the front end, the content does not appear updated.
We'd like to know how you are querying your Prismic API with Nuxt & PHP and how you provide that data to the frontend.
If you query Prismic from the backend, this can cause issues with Previews if the cookie is only created on the frontend, not forwarded to the backend, or the other way around.
We've managed to get the Previews working on another preview site that we have, but some of the content doesn't load which I suspect might be a problem with the way nuxt is generating the pages, since that is using Server Side Rendering.
Nuxt handles preview sessions easily on its own. So with PHP on top, it can get tricky.
You'd need to check if the preview cookie is forwarded to the API. You need to check if the result of the getPreviewRef function returns a string, not null when running a preview session. If this doesn't happen, you can try and forward the preview cookie to the API in a query.