Note: When testing, ensure that caching is enabled in the browser (i.e. the "Disable cache" setting is unchecked) and that the DevTools is closed.
Deploy site to Vercel
Edit a page and preview on production
Exit the preview and verify Preview Mode is no longer active
Start a new preview
Exit the preview and verify Preview Mode is still active
What is expected?
Previews exit as many times as needed.
What is actually happening?
It only exits the first time. Any subsequent attempt is not exited. However, the Prismic preview token is removed and the request to /api/exit-preview is successful.
This happens because the endpoint returns a 200 status code. Vercel caches 200 GET requests at the Edge. To prevent the endpoint from being cached, a non-200 status code must be sent, or a non-GET request must be used.
Versions
@prismicio/next
: v0.1.3next
: v12.2.4Reproduction
https://github.com/prismicio-community/nextjs-starter-prismic-blog
Steps to reproduce
Note: When testing, ensure that caching is enabled in the browser (i.e. the "Disable cache" setting is unchecked) and that the DevTools is closed.
What is expected?
Previews exit as many times as needed.
What is actually happening?
It only exits the first time. Any subsequent attempt is not exited. However, the Prismic preview token is removed and the request to
/api/exit-preview
is successful.This happens because the endpoint returns a 200 status code. Vercel caches 200 GET requests at the Edge. To prevent the endpoint from being cached, a non-200 status code must be sent, or a non-GET request must be used.
More details are available here: https://vercel.com/docs/concepts/functions/serverless-functions/edge-caching