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

Update limitations.md #370

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update limitations.md #370

wants to merge 1 commit into from

Conversation

ianjamieson
Copy link

@ianjamieson ianjamieson commented Jan 9, 2025

Description

While running a nuxt application on Cloudflare workers. I noticed that no cookies were being found server side.

Inside the useCookie composable that comes with nuxt there is some logic to check if the cookie has expired:

https://github.com/nuxt/nuxt/blob/41cdaf670247004eab95395910b4a59e87e38bd9/packages/nuxt/src/app/composables/cookie.ts#L46-L55

When defining a store like this:

export const useStore = defineStore(
  'main',
  () => {
    const someState = ref('hello pinia')
    return { someState }
  },
  {
    persist: piniaPluginPersistedstate.cookies({
      expires:  new Date(new Date().setFullYear(new Date().getFullYear() + 1)) 
    }),
  },
)

The date was considered to be the global context, which Cloudflare says will return 1970-01-01.

As a solution in the limitations, I have proposed to use maxAge instead of expires.

Additional Info

This is hard to reproduce on Stackblitz as this code needs to be running on a Cloudflare worker. You can set up something basic like the above and notice that the cookie will always e expired on the worker server side.

Include an additional limitation which arises using nuxt with cloudflare and the expires property with the cookie storage  mechanism.
@ianjamieson ianjamieson requested a review from prazdevs as a code owner January 9, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant