Nuxt 3 page refresh deletes cookies

Viewed 19

I have such useCookie function

import { watch } from 'vue'
import { useCookie, useState } from '#imports'
import type { CookieOptions } from '#app/composables/cookie'

export const useOxyAsyncCookie = <T>(key: string, options?: CookieOptions) => {
  const cookie = useCookie(key, options)
  const state = useState<T>(key, () => cookie.value)

  watch(state, (value) => {
    cookie.value = value
    state.value = value
  })

  return state
}

I'm using it like this

authToken = useOxyAsyncCookie(AUTH_TOKEN, {
  default: () => data.value.raw.token,
  expires,
})
let authToken = useOxyAsyncCookie<string>(AUTH_TOKEN)

I have multiple projects using this function, on one of them the cookies beeng deleted after regular page refresh(without implicitly deleting the cookies)

My question is: what can be wrong and how can i know what is happening with cookies after refresh?

0 Answers
Related