Skip to content
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

clearPreviewData() doesn't work with custom path #39853

Closed
1 task done
mehulmpt opened this issue Aug 23, 2022 · 1 comment · Fixed by #40238
Closed
1 task done

clearPreviewData() doesn't work with custom path #39853

mehulmpt opened this issue Aug 23, 2022 · 1 comment · Fixed by #40238
Labels
bug Issue was opened via the bug report template.

Comments

@mehulmpt
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T8101
Binaries:
Node: 16.14.2
npm: 8.6.0
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.2.5
eslint-config-next: 12.0.4
react: 17.0.2
react-dom: 17.0.2

What browser are you using? (if relevant)

104.0.5112.101

How are you deploying your application? (if relevant)

No response

Describe the Bug

Custom path option for preview mode was added in #38313 however the clearPreviewData method was not updated. Currently, it does not clear the preview mode on custom paths (as it sets the expiry cookie on / by default, instead of a custom path specified with res.setPreviewData)

A potential fix is to allow res.clearPreviewData to accept a path argument on which to expire the Next.js preview mode cookies.

Expected Behavior

res.clearPreviewData() should work on custom paths too

Link to reproduction

https://codedamn.com/playground/mLua3PAdbeGQLmJZVS5cf

To Reproduce

  1. Open https://codedamn.com/playground/mLua3PAdbeGQLmJZVS5cf
  2. Open the embedded iframe view on right in new tab (from top right)
  3. Try to set and remove preview mode
@mehulmpt mehulmpt added the bug Issue was opened via the bug report template. label Aug 23, 2022
ijjk added a commit that referenced this issue Sep 5, 2022
As updated in #38313 this ensures the `path` option can also be passed to `clearPreviewData` to properly clear the preview cookies. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: #39853
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant