microcipcip/cookie-universal

app.$cookie.set not working

Opened this issue · 2 comments

Hi,

I have an universal app and I'm using cookie-universal-nuxt to configure cookies.
I'm using a middleware to read cookies and Vuex store to set cookies.

Middleware

export default function (context) {

  let token;
  let expirationDate;

  if (process.browser) {
    token = localStorage.getItem('token');
  } else {
    token = context.app.$cookies.get('jwt');
  }

  context.store.dispatch('initAuth', token);
}

Store

authenticatedUser(context, result) {

  context.commit('setToken', result.idToken);
  localStorage.setItem('token', result.idToken);
  context.app.$cookies.set('jwt', result.idToken);

}

Local storage is working normal.

Did you fix this issue? What mode are you using? Universal? Is the function context.app.$cookies.set defined or undefined?

I used a different approach. context.app.$cookies.set is defined at the beginning of the project.