[ ] Chore (a non-breaking change which is related to package maintenance)
[x] Bug fix (a non-breaking change which fixes an issue)
[ ] New feature (a non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
This PR fixes a bug where preview content would not appear when using a shared preview link.
If @prismicio/next's redirectToPreviewURL()defaultURL option pointed to a page that doesn't exist (i.e. a 404 status code), the page would not be refreshed. This happens because <PrismicPreview> checked for res.ok when fetching the /api/preview endpoint.
Rather than check for res.ok, which may result in a 404 despite properly updating preview data, <PrismicPreview> now checks that res.redirected is true.
Checklist:
[ ] My change requires an update to the official documentation.
[x] All TSDoc comments are up-to-date and new ones have been added where necessary.
Types of changes
Description
This PR fixes a bug where preview content would not appear when using a shared preview link.
If
@prismicio/next
'sredirectToPreviewURL()
defaultURL
option pointed to a page that doesn't exist (i.e. a 404 status code), the page would not be refreshed. This happens because<PrismicPreview>
checked forres.ok
when fetching the/api/preview
endpoint.Rather than check for
res.ok
, which may result in a 404 despite properly updating preview data,<PrismicPreview>
now checks thatres.redirected
is true.Checklist:
🐳