-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: set cookie path when entering preview mode #552
Conversation
🦋 Changeset detectedLatest commit: 30ba50c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📦 Next.js Bundle Analysis for @10up/headless_frameworkThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
1 similar comment
📦 Next.js Bundle Analysis for @10up/headless_frameworkThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
📦 Next.js Bundle Analysis for @10up/headless_frameworkThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
📦 Next.js Bundle Analysis for @10up/headless_frameworkThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Description of the Change
This PR improves the Next.js preview cookie handling.
First of all, it sets the preview cookie to expire within 5 minutes which aligns with the JWT token expiration.
Secondly, it will narrow the cookie to the post path being previewed so that
context.preview
is not true for other paths and thus avoiding bypassinggetStaticProps
(among other potential issues) until the cookies are cleared (either expires or the browser closes).This would also let us eventually get rid of the requirement of having "-preview=true" in the URL.
How to test the Change
Preview a post and check if the cookies
__prerender_bypass
and__next_preview_data
haspath
set to the actual path being previewed.Alternatively, you can also test with a production build whether
getStaticProps
are not running for every request after previewing a post.Checklist: