Most unexpected, but error state can be replicated locally by amending hosts file to point 127.0.0.1 to test.com.
Working: localhost:3000/api/preview, and banana:3000/api/preview
Not Working: test.com:3000/api/preview (shows Prismic client error: "No documents were returned" from within getStaticProps)
Exact same code and machine environment across both
Printing to console the params arg in getStaticProps on banana:3000 (working) in preview mode shows the correct value for the page we are previewing, i.e. { uid: [ 'test-page' ] }
However on test.com:3000 (not working) the console shows { uid: [ 'preview', 'api' ] }
Hi @chris.m
Did you try to preview a document on production without using the sharable link does it work? in fact, anonymous share links work with Next.js when set up with @prismicio/next .
We are experiencing this issue when we click the Preview button within the document edit screen. I have just tried the shareable link from the preview toolbar and it produces the same result.
UPDATE - Further discovery...
I can narrow the issue to Prismic documents NOT published at the time of previewing.
If the document has been published, thus available publicly, editing the document further and clicking the save button (document now orange), followed by the preview button, this will indeed render the page in preview mode with the proposed content change(s).
However, if a new document is created (not yet published), or if a published document is unpublished (site then rebuilt on the server without this page), content then changed, save button then clicked (document now orange), preview button then clicked -> this leads to the 404 page.
The above behaviour is only present on our Vercel staging/production environment. Locally however (localhost:3000), preview mode always works whether it's an already published document, or if it's a completely new not yet published document.
Hi @chris.m
I have checked with my team, and they have confirmed if the preview is working entirely on your local host, then the problem must be a configuration on vercel side; you can check if on Vercel you haven't blocked the preview endpoint
Hi @marketing10
In fact, this issue is not the same, and in your case, you can't see your Slices in Prismic, and for that, I will split this Post and create a new issue with it.