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
Docs: potential preview-mode error on production build #34129
Comments
Sounds good! Here is the file if anyone wanted to open a PR to fix this: https://github.com/vercel/next.js/blob/canary/docs/advanced-features/preview-mode.md |
Does using a |
I'm happy to add a note about it to the docs |
Add note to 'Clear preview mode cookies' that explains the need to pass `prefetch={false}` to `Link` component to prevent clearing cookies accidentally. (Docs: potential preview-mode error on production build vercel#34129)
…(issue #34129) (#34142) Add note that explains the need to pass `prefetch={false}` to `Link` component to prevent clearing cookies accidentally (responding to issue "Docs: potential preview-mode error on production build #34129"). Note as follows: > **Note:** If calling this route using `Link` component, you must pass in `prefetch={false}` to prevent calling `clearPreviewData` during prefetch. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ x] Make sure the linting passes by running `yarn lint`
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What is the improvement or update you wish to see?
Under the Clear the preview mode cookies section, It might be worth mentioning one should NOT use
<Link href="/api/to/clear/cookies/">...</Link>
to clear the preview-mode cookies.Is there any context that might help us understand?
<Link />
are automatically prefetched in production built. When<Link href="/api/to/clear/cookies/">Exit Preview</Link>
button is shown in preview mode, it gets prefetched and the preview cookies are cleared immediately.In my case, the server is crashed whenever user enters preview mode (due to res.redirect() logic in my /preview/ api); in other setup, it might cause other unexpected behaviour.
The fix is simple though, simply use an tag and the issue is gone.
Does the docs page already exist? Please link to it.
https://nextjs.org/docs/advanced-features/preview-mode#clear-the-preview-mode-cookies
The text was updated successfully, but these errors were encountered: