Setting SameSite cookie attributes in Nuxt

Viewed 699

I'm learning Nuxt.js and I assigned some data to localStorage (using localStorage.getItem() and localStorage.setItem()) which worked great, but I'm getting a warning: Cookie “myCookieName” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute.

After reading about it here, I think I would like to set it to strict, but I have no idea where to actually set it.

Any tips would be highly appreciated. Many thanks!

1 Answers

You can use the cookie-universal-nuxt package for playing with cookies (there are many others but this is perfect for SSR).

Then after you can set cookie attributes via this module options in nuxt.config.js

{
  modules: [
    ['cookie-universal-nuxt', { SameSite: 'Strict' }],
 ]
}
Related