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

Error page lost pinia state #14968

Closed
senher opened this issue Sep 20, 2022 · 5 comments
Closed

Error page lost pinia state #14968

senher opened this issue Sep 20, 2022 · 5 comments

Comments

@senher
Copy link

senher commented Sep 20, 2022

Environment

"nuxt": "3.0.0-rc.10",
"@pinia/nuxt": "^0.4.2",

Reproduction

"nuxt": "3.0.0-rc.10",
"@pinia/nuxt": "^0.4.2",

Describe the bug

I get global data in app.vue, verify user in middleware global.global and save them in pinia (for example get token in cookie and save in pinia);
When I get to an error page and try to refresh it with keyboard F5;
At this time I click the back to home button on the page, pinia will disappear,
All state data will be lost;
They work fine if I don't refresh the error page;

Additional context

No response

Logs

No response

@aesyondu
Copy link

I think you will have to use local storage to persist state on client side.

Maybe this package will help https://github.com/prazdevs/pinia-plugin-persistedstate

@danielroe
Copy link
Member

Would you provide a reproduction? 🙏

@Kolobok12309
Copy link
Contributor

If you get error-page while ssr, you lost all your headers and also cookie, mb it help with it #14842

@senher
Copy link
Author

senher commented Sep 21, 2022

Would you provide a reproduction? 🙏

Would you provide a reproduction? 🙏

https://stackblitz.com/edit/github-7egzqc?file=middleware/global.global.ts

Copy link
Member

Thank you. Yes, I think this is the same issue as #14842. Error pages are meant to be cacheable so they are rendered in a separate, internal request without the original request headers. And in general, they need to handle unforeseen errors, so I would suggest making them as free of dependencies on other parts of your app as possible.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants