@Phil Thanks for the response. I saw this message, but unfortunately, this is not the issue. I have put the script that within app.html and the 404 page uses that template as well for its page.
The issue is something else that needs to be investigated and fixed.
I don't know why this isn't working server-side with src/routes/preview.js. However, it's relatively easy to make previews work client-side.
The issue seems to be that the server isn't receiving the cookie. In my implementation, the page reloads and the server receives the cookie on the second try, so everything works fine, but if I look at the console I can see the same error that you're getting.
So, my solution for now is to switch to client-side routing. Delete src/routes/preview.js and create src/routes/preview.svelte, then paste in this code:
Many thanks for looking into this. It does seem to fix it for the first load of the webpage, but if I Save another change while the browser is still open, it does refresh but the page doesn't render with an error:
Failed to load resource: the server responded with a status of 404 (Not Found)
@kris My colleague @angeloashmore suggested a tweak to the official implementation to make the cookie available immediately. Would you be willing to try this and let me know if it works? It means reverting to your original implementation, and changing src/routes/preview.js to this:
@samlittlefair ,I upgraded to the newest routing API and I following the documentation. The previews work for pages that already exist, but the the same error appears for 404 pages:
Failed to load resource: the server responded with a status of 404 (Not Found)
I just want to double check - have you tested the documentation in a test repository internally? If so, can you share a github repository with a working preview for drafts?
@kris Yep, I have this working with a minimal setup, following the docs step-by-step. Here's the app; you just need to update the repo name and routes option in src/lib/prismicio.js, and update the folder structure and querying if necessary.
Let me know if that still throws an error. If so, let me know the error. If not, let's keep trying to debug your project to see what the difference is.