People searching “Laravel API versioning Vue” mount Inertia on /api/v1 or prefix the file twice and call /api/api/v1. bootstrap/app.php already gives routes/api.php the api prefix and the api middleware group. Add only the version:
TL;DR
- routes/api.php is already under /api.
- Add v1 inside the file and keep Inertia pages out of it.
- Do not point an Inertia Link at
/api/v1/postsfrom a page. - Do not duplicate the whole web CRUD under
v1when Inertia already renders those pages.
The fix#
Route::prefix('v1')->middleware('auth:sanctum')->group(function () {
Route::get('/posts', [Api\PostController::class, 'index']);
});The URL is /api/v1/posts. It returns JSON. The Vue starter kit does not navigate there. A separate SPA, the one in the SPA guide, is the client that calls it. Cookie auth for that SPA is the Sanctum guide. A token is a different client.
What to avoid#
Gotcha
Do not point an Inertia Link at /api/v1/posts from a page. Link expects an Inertia response. A JSON body mounts as a broken visit. Do not duplicate the whole web CRUD under v1 when Inertia already renders those pages.
FAQ#
How do I prefix a Laravel API with v1?
routes/api.php is already under /api. Add v1 inside the file and keep Inertia pages out of it.
What goes wrong with Laravel API versioning Vue?
Many developers mount Inertia on /api/v1 or prefix the file twice and call /api/api/v1. Do not point an Inertia Link at /api/v1/posts from a page.



