strapi icon indicating copy to clipboard operation
strapi copied to clipboard

Strapi can't detect $strapi.user on page refresh

Open adhamfarrag opened this issue 3 years ago • 1 comments

Actually problem starting happening months ago and I didn't realize it. Focused on short fixes by moving $strapi.user to another store object and use it from there. Application works well beside page refreshing, in development mode I lose $strapi.user, in production it logs user out.

Tried modifying middleware to rely on strapi cookie instead of $strapi.user and it stopped logging me out.


export default function ({ app, redirect }) {
  if (!app.$storage.getCookie('userJwt')) {
    redirect('/login')
  }
}

But now I have strange behavior, which's is on page refresh, it doesn't log me out as cookie is still there, but some reason storage gets wiped in production, dev mode it works perfectly.

adhamfarrag avatar Dec 30 '21 22:12 adhamfarrag

Tried following solutions presented in #138 but didn't help.

adhamfarrag avatar Dec 30 '21 22:12 adhamfarrag

Can you reproduce it with latest strapi module?

atinux avatar Mar 04 '23 07:03 atinux