auth-module: Prevent User Request on index page(before login) Not Working : Laravel sanctum (Token Based Authentication))
I’m Using Nuxt Auth Module With Laravel Sanctum
Issue are the user request is being sent automatically when the page starts, even though I’m not login or trying to login

my nuxt.config.js file is :
auth: { strategies: { local: { endpoints: { login: { url: '/login', method: 'post', propertyName: 'token' }, logout: { url: '/logout', method: 'post' }, user: { url: '/user', method: 'get', propertyName: 'user' }, }, } }, redirect: { login: '/login', logout: '/login', callback: '/login', home: '/dashboard' } },

I’m also trying user property to (propertyName: false ) or (propertyName: ’ ’ ) but not working
store/auth.js `export const getters = { authenticated(state, getters, rootState){ return rootState.auth.loggedIn; },
user(state, getters, rootState){
return rootState.auth.user;
}
}`
How to Stop this first request for a user that automatically occurs. any solutions
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15
For me what works best is to disable the user endpoint entirely like that:
And to avoid the user request immediately after login (because it would be redundant) just return your user info on the login POST response and then:
After that you can even take advantage of that and only make a request on reload, something like that:
In other words:
user: falsein nuxt.config.jsthis.$auth.setUser()method to set the user manually.@nikolayandreev where we can call this method