Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christianvolk's avatar

Laravel API + Vue Frontend

I would like to build a Laravel API and a completely separated Frontend, for example with Vue. API and Frontend would be on separated servers.

Are there any Tutorials that teach the Best Practice? Most important thing would be the authentication (User Login + API-Authentication), because the Application has to handle sensitive data.

I searched for something like that in the laracasts-tutorials, but did not find something like that.

0 likes
2 replies
christianvolk's avatar

I was not sure if it is safe enough to send credentials simply with axios, but it seems that this is the common way to do what i want to do.

My authentication steps:

  1. Post username and password with axios
  2. Validate credentials with laravel-passport
  3. Return api-token if credentials are correct
  4. store api-token in localstorage
  5. use api-token for every request against laravel-backend
  6. if api-token is invalid return authentication error else return requested data
  7. listen for auth-error in vue and maybe go to login-page or something like that

Would that be the correct or at least one correct way to do it? I wonder if that is safe enough.

Edit: if api-token is available from localstorage, that means user is logged in and the process would start with number 5

Please or to participate in this conversation.