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

Router clears Options in the window.history.state #8634

Closed
nkrivous opened this issue Sep 5, 2019 · 2 comments
Closed

Router clears Options in the window.history.state #8634

nkrivous opened this issue Sep 5, 2019 · 2 comments

Comments

@nkrivous
Copy link

nkrivous commented Sep 5, 2019

Bug report

Describe the bug

It seems that next-server router clears Options object from the window.history.state.

To Reproduce

  1. store something in the window.history.state
  2. refresh the page to recreate Router object
  3. Options object is empty

Expected behavior

Router recreate Options in the window.history.state

Additional context

I've investigated that problem has its roots in the Router constructor
https://github.com/zeit/next.js/blob/canary/packages/next/next-server/lib/router/router.ts#L129
It calls method this.changeState(...) without passing Options object. And default value for Options is empty object {}.

pavelzubov added a commit to pavelzubov/next.js that referenced this issue Sep 16, 2019
Set history options if window.history.state is defined
@pavelzubov pavelzubov mentioned this issue Oct 7, 2019
@Timer Timer added this to the 9.1.x milestone Oct 16, 2019
@Timer Timer modified the milestones: 9.1.x, 9.2.x Jan 3, 2020
@timneutkens
Copy link
Member

window.history should not be manipulated outside of the router as that will cause the router to go into a bad state when using the back button.

Re-opened #771 because as of right now manipulating history is expected to break.

@Timer Timer removed this from the 10.x.x milestone Nov 16, 2020
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants