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

hanzanati's avatar

Use same API routes with Inertia and external calls

With Laravel 8 and Inertia, we would like to build our API that Intertia routes will be using, i.e. resource calls for models, but also have those same routes be available for our external applications to community.

Since we are using the sanctum middleware, how should we setup our middleware so both Intertia and external calls can properly authenticate, or will this work by default?

0 likes
2 replies
Sinnbeck's avatar

Any reason why ? That does not sound very "single responsibility" to me :) Why not just have some actions that both controllers can call, and routes for api in the api.php file

hanzanati's avatar

@sinnbeck - Yeah, that's where I was leaning anyway - just trying to reduce code and endpoints for development, but it's really not that much extra code and goes against single responsibility. Thanks for your time!

Please or to participate in this conversation.