I didnt had the EnsureFrontendRequestsAreStateful on the kernel.
Apr 19, 2024
1
Level 1
Laravel Vue Spa with Fortify and Sanctum return unauthorized user after succeful login.
Hello Laravelers,
Today I just want to try the fortify as a SPA with Vue and I have the 401 unauthorized error. All I need a user to login and logout for now. I follow all the steps on the docs and I check the internet for solutions but I was unlikely. My vue is inside the laravel on the same domain. In fortify configs i turn off the views. I change the App url to the project url laravel.test. Then follow the docs and some examples to build the app.
Problem: Login successfully but when called the /api/user then return 401
Questions:
- I need to setup the
SANCTUM_STATEFUL_DOMAINSon the sanctum configs? - Need to wrap the vue app instance with
attemptUseror doesnt need?
attemptUser().finally(() => {
const app = createApp(App)
app.use(router)
app.mount('#app')
}))
Level 1
1 like
Please or to participate in this conversation.