Laravel Passport API
Hello,
i have a little problem and i hope you can help me with this.
I actually try to seperate my frontend from my backend.
I have a backend-application with laravel, and a frontent application with vue (vue-cli).
So i tried to get into laravel with passport to secure the Vue-SPA API-Routes.
What i want:
- calling from my frontend with axios to the backend with axios to get data
- login/out users
- if possible redirect if users are idle too long
- realtime events with pusher from the backend to the frontend
My Backend should stay standalone, so that i can create a list with my api routes and call them from any "frontend" that i want to.
I want it mainly to learn how to buid such a setup.
What i dont know:
- how to set up a login with passport and vue or better said what is best practice for this?
- is passport at least a good idea to try to realise this?
- redirect if idle is a riddle i cant solve..
- is it possible to realise pusher events with 2 seperated servers and laravel echo? (i belive it should work, but a simple yes or no would help my ego)
This was much blah and much i want, i want, i dont know, i want.
I would appreciate any tipp, link or help that you could give me to get this done.
I read many articles and looked into even more example builds but i have the feeling that i miss a huge load of knowledge in this area as a hobby web developer.
I could login with postman and retrieve my token, but what to do then? Where to store the token? When does the token gets invalid? Where does the secret and the client id needs to get used? I read articles about hardcoding the secret in the frontend, but for what, and why?
Is the order of events, that i login to a public route, then i check if there is a user with those credentials and then send back a success message with the token?
Then save the token and call api calls with axios with the token in the header?
Sorry for the long post, but i get to my limits with this topic. After weeks of reading and testing and only tiny pieces of success i get a little bit depressed.
Please or to participate in this conversation.