diff --git a/packages/nuxt/src/app/composables/cookie.ts b/packages/nuxt/src/app/composables/cookie.ts index 4898b86b27..26f31318a1 100644 --- a/packages/nuxt/src/app/composables/cookie.ts +++ b/packages/nuxt/src/app/composables/cookie.ts @@ -3,6 +3,7 @@ import { parse, serialize, CookieParseOptions, CookieSerializeOptions } from 'co import { appendHeader } from 'h3' import type { CompatibilityEvent } from 'h3' import destr from 'destr' +import { isEqual } from 'ohash' import { useRequestEvent } from './ssr' import { wrapInRef } from './utils' import { useNuxtApp } from '#app' @@ -34,7 +35,7 @@ export function useCookie (name: string, _opts?: CookieOptions): C } else if (process.server) { const nuxtApp = useNuxtApp() const writeFinalCookieValue = () => { - if (cookie.value !== cookies[name]) { + if (!isEqual(cookie.value, cookies[name])) { writeServerCookie(useRequestEvent(nuxtApp), name, cookie.value, opts) } }