I’ve setup my ecommerce frontend in next js 13 (App directory) and backend in laravel with scantum.
I’m not using laravel breeze since admin users use laravel for backend CRUD operation.
I’m confused how/where to save the token returned by backend in next js frontend. So that i can use it for other GET/POST requests.
Can i use next-auth for this process ? I would be thankful if someone could share any ideas on this.
2
Answers
After researching for week I'm able to connect with scantum by the following method.
If you are reading in future and have better approach feel free to post your answer.
If you need to store a Sanctum token in your frontend, you can do so using the following method.
above method will store the sanctum token in local storage.
you can access it whenever you need it using the following method,
Let’s say you have to pass it in an axio API request, then you can do it like below.