NUXT_E7011

A cookie could not be written.

E7011

useCookie() could not serialize a cookie for the Set-Cookie header or document.cookie. The original error is attached as cause. It is raised when:

  • the cookie name contains characters that are not allowed in a cookie name, such as spaces, ; or =
  • the value returned by a custom encode contains characters that are not allowed in a cookie value
  • the attributes are inconsistent, for example sameSite: 'none', partitioned: true or a __Secure- / __Host- name without secure: true, or a __Host- cookie with a domain
  • an attribute is invalid, for example a maxAge that is not an integer

Resolution

Use a valid cookie name, return an encoded string from encode, and set secure: true for cookies that require it:

const token = useCookie('token', {
  sameSite: 'none',
  secure: true,
})
Read more in Docs > API > Composables > Use Cookie.

Was this helpful?