Can you move the Axios POST from setup to the onMounted hook?
[Inertia/Vue] 419 Token Mismatch Error on subcomponent right after login
I have a weird phenomenon I can't wrap my head around. My APP is laravel 11, jetstream, inertia/vue based
After Login I am correctly redirected to the Dashboard. The Dashboard fetches Data via Axios_GET (during setup) and displays them, at the same time the Dashboard has a subcomponent (vue) which also during setup makes an Axios POST Call to display GraphData. Right after login, the Dashboard correctly displays the GET data while the GraphSubcomponent always fails with a 419. Always just right after login! Only if I refresh the page the data get loaded correctly.
XHRPOST
http://localhost:63347/api/getSaldoSnapshots?portfolioId=1
[HTTP/1.1 419 unknown status 23ms]
message "CSRF token mismatch."
OK, I can understand that a POST request is different than a GET and I probably could solve that issue by rewritig the Post request to an URL parsed get request, perhaps. But i want to understand: I dove deeper and the POST request is sending the X-CSRF-Token in the headers. So I quite don't get the Token Mismatch error in this context, because it's right after login! Would it perhaps to refresh the X-CSRF-Token right when landing in the dashboard, before the component is setup or something like that?
Btw: I also get a 419 Error (although Page Expired) when trying to access my login page right after a logout. I don't know if that is related but apparently something isn't quite right in my app (yet). I am using 3 layouts (non-login context, auth context and app context), the app-context is a SinglePageApp and vue-router based while Web & Auth are laravel router based.
Please or to participate in this conversation.