loading...

Discussion on: PKCE authenticaton for Nuxt SPA with Laravel as backend

Collapse
thorbn profile image
Thor

Hi again Stefan,

With the code you have written, the user logges out when refreshing the page, howto handle so the user don't logges out on page refresh?

The attached screendump is what I have after page refresh

dev-to-uploads.s3.amazonaws.com/i/...

Collapse
stefant123 profile image
StefanT123 Author

On page reload, check for the token in cookies, and if there is a token in the cookies, just set it in axios

Collapse
thorbn profile image
Thor

I did:

In authIt.js

const access_token = cookies.get('x-access-token');
if
no token redirect to /login

else

store.$axios.$get(process.env.LARAVEL_ENDPOINT+'/api/user')
.then(resp => {
store.$auth.setUser(resp)
......