2 months ago

Laravel Sanctum + Nuxt.js

Posted 2 months ago by lumore

Hi everyone, I've just created fresh Laravel & Nuxt projects, and trying to connect SPA auth through Sanctum package:

const cookie = await this.$axios.get('/sanctum/csrf-cookie')
const login = await this.$'/login', this.form)

"cookie" response gives status code of 204 with header Set-Cookie, but I checked chrome devtools and in Application tab Cookie storage is empty, so the second request (login) throws an error "CSRF token mismatch".

Both projects are with default cors & axios settings, I've only added "withCredentials: true" line to the axios config. I would appreciate any help with this.

Please sign in or create an account to participate in this conversation.