No, you just need to send the CSRF with your Javascript request as long as you're sending it from the same app domain.
Nov 28, 2022
7
Level 1
Authenticate user for both standard and SPA pages
Hello,
I use Inertia with Svelte to build my app and I manually authenticate users (https://laravel.com/docs/9.x/authentication#authenticating-users), which works for all the pages except for modal dialogs where I use JS fetch to get data from the API routes (with fetch Auth::user() is NULL). I looked up SPA authentication and it seems like I need to use Sanctum to authenticate API calls. Does it mean the user needs to authenticate twice, once the standard way, and another for AJAX calls. Can I have the single login form for both? Can you please point me in the right direction? Thanks!
Level 51
Please or to participate in this conversation.