Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): better equality check for json cookies (#6352)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 4, 2022
1 parent d8cdd97 commit 4732d2c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/nuxt/src/app/composables/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -34,7 +35,7 @@ export function useCookie <T=string> (name: string, _opts?: CookieOptions<T>): 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)
}
}
Expand Down

0 comments on commit 4732d2c

Please sign in to comment.