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

panthro's avatar

Use API routes?

My website is a mix of HTML and VUE components.

HTML data is populated via PHP on server.

VUE data is populated by axios calls to API routes.

At this stage I have no need for an external iOS/Android app (but may do in the near future). So the data is only currently being consumed by my website.

  1. Should the VUE routes sit under API routes (and thus implement some sort of token auth - passport etc).
  2. If the answer to the first question is yes, should my web routes and controllers consume my API internally - or should they just talk to my service class (the same service class the API controllers use) to get the data.

Thank you

0 likes
3 replies
drewdan's avatar

In an application I work with, our Vue components axios requests hit our normal controller routes, and we have API controllers for the external app. Both components reach into the service layer to prevent code duplication. So I would not stick your vue stuff under the API routes unless your vue stuff is a separate application. But that's just how we do it, not saying it's the best approach, but it works well for us :)

Please or to participate in this conversation.