Closed kb1995 closed 2 years ago
This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.
Hi there, thank you so much for the report!
Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:
package.json
file.If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request address it. Check out our quick start guide for a simple contribution process.
If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io
- The Prismic Open-Source Team
Hey @kb1995, I was away on vacation but I'm back now. 🙂
There was a bug in @prismicio/next
that caused this exact issue when deploying to CDNs that aggressively cache API route responses, including Vercel. This is fixed as of v0.1.4
where exitPreview()
now returns a 205 status code.
For more details on the issue and the fix, see #32.
I see you're using at least v0.1.5
, which already includes the fix, so you may have a cached response stored in your browser. Could you clear your browser cache (specifically for the /api/exit-preview
route) and try again? You should see a 205 status code on the /api/exit-preview
route, not a 200.
Please let me know if this fixes the issue. Thanks!
I'm going to close this issue as it has become stale, but feel free to reply here. We can continue the discussion and re-open if necessary. Thanks! 🙂
hi @angeloashmore we get a 500 error when calling exitPreview using draftMode().disable().
Steps to recreate:
Is this expected behavior? it seems it is based on the code.
`if (config?.res) { // Assume Preview Mode is being used.
config.res.clearPreviewData();
// `Cache-Control` header is used to prevent CDN-level caching.
config.res.setHeader("Cache-Control", "no-store");
config.res.json({ success: true });
return;
} else {
// Assume Draft Mode is being used.
draftMode().disable();
// `Cache-Control` header is used to prevent CDN-level caching.
return new Response(JSON.stringify({ success: true }), {
headers: {
"Cache-Control": "no-store",
},
});
}`
This only happens on unpublished drafts, but is there any way to improve this experience? maybe redirect content editor to homepage?
Packages version:
api/exit-preview.js
is as follows:Steps to reproduce: