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

[nuxt] Cookie persistence broken on Netlify builds #269

Open
4 tasks done
fanckush opened this issue Jan 12, 2024 · 4 comments
Open
4 tasks done

[nuxt] Cookie persistence broken on Netlify builds #269

fanckush opened this issue Jan 12, 2024 · 4 comments
Labels
✋ help wanted Extra attention is needed

Comments

@fanckush
Copy link

Describe the bug

on my local dev server cookie based persistence (default config) works fine
when I deploy the site to on netlify, I can see pinia trying to set the cookie but the name is being set to '' blank and the value is set to undefined. While on the dev server the cookie name is main and the value is the encoded store

Dev server on localhost
image

Netlify deploy
image

**note: ** i'm not 100% sure that the reproduction is useful. while the bug occurs there as well, I don't know if the reason is the same. i'm happy to debug this however you suggest.

Reproduction

https://stackblitz.com/edit/github-4dwbqx-jbccag?file=package.json,nuxt.config.ts,app.vue,composables%2Fstore.ts,package-lock.json

System Info

System:
    OS: macOS 14.1.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 166.42 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - /opt/homebrew/opt/node@20/bin/node
    npm: 10.2.4 - /opt/homebrew/opt/node@20/bin/npm
    bun: 1.0.22 - /opt/homebrew/bin/bun
  Browsers:
    Brave Browser: 120.1.61.116
    Safari: 17.1

Used Package Manager

bun

Validations

@fanckush fanckush added the 🔍️ pending triage This issue needs to be looked into label Jan 12, 2024
@fanckush fanckush changed the title Cookie broken on production build Cookie persistence broken on Netlify builds Jan 12, 2024
@prazdevs
Copy link
Owner

Yeah, the stackblitz you gave works perfectly fine (open the preview in a new window to have it working).
Curious to see if it's Netlify specific or some other SaaS have issues. I've had issues with Netlify building the app couple times so idk. I'll eventually take a look whenever.

Have you tried playing around using localStorage instead of cookies to see if the problem is cookies or the plugin itself ?

@fanckush
Copy link
Author

just tested, localStorage works fine 👍🏼
i'll stick with that for now

@prazdevs
Copy link
Owner

However be mindful of using data from the store, as it will be rehydrated only when the client is hydrated as well. So data from the server is not the same as the one in the client

@prazdevs prazdevs added ✋ help wanted Extra attention is needed and removed 🔍️ pending triage This issue needs to be looked into labels Jan 19, 2024
@prazdevs prazdevs changed the title Cookie persistence broken on Netlify builds [nuxt] Cookie persistence broken on Netlify builds Jan 28, 2024
@fanckush
Copy link
Author

fanckush commented Feb 8, 2024

I was using ssr: false so far. Now that I switched to ssr, I get the hydration mismatch. Is there another storage mechanism I could use that is read by the server as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✋ help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants