How to do Sveltekit authentication using Laravel Sanctum #2767
Replies: 2 comments
-
As long as you're using something like the Node adapter, this should be possible. Serverless solutions like Netlify/Vercel will need different approaches for auth. I would suggest using the native |
Beta Was this translation helpful? Give feedback.
-
You may follow my guide here https://github.com/daison12006013/sveltekit-starter/blob/develop/guides/laravel-sanctum.md |
Beta Was this translation helpful? Give feedback.
-
I want to ask how to do the authentication using Sveltekit and Laravel sanctum, I have already set up the Laravel backend and I am able to log in using email and password. After I logged in I got the cookie from the Laravel backend.
The first thing that I tried using Axios to make a login request to the server. The subsequent request to the server will automatically be treated as a logged-in user.
but when I make a request from
<script context="module">
it will be treated as the unauthenticated user.My assumption is that the cookie from laravel sanctum is saved on the client-side. meanwhile, the second request is made on the server so it doesn't have the cookie.
What is the best approach to authenticating users using Laravel sanctum?
Beta Was this translation helpful? Give feedback.
All reactions