prismicio / prismic-next

Helpers to integrate Prismic into Next.js apps
https://prismic.io/docs/technologies/nextjs
Apache License 2.0
57 stars 7 forks source link

fix(exitPreview): prevent "Cannot set headers after they are sent to the client" warning in the Pages Router #74

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR fixes a bug where exitPreview() tirggered the following warning when used in the Pages Router:

Cannot set headers after they are sent to the client

This warning was triggered by calling res.setHeader() after res.json(), which is not allowed.

Checklist: