# 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.

- URL: https://laravel-vuejs.space/laravel-api-v1-prefix-vue
- Author: Anass Ez-zouaine (https://laravel-vuejs.space/author/anass-ez-zouaine)
- Published: 2026-10-11
- Topics: Laravel, VueJs, Sanctum

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/posts` from a page.
> -   Do not duplicate the whole web CRUD under `v1` when Inertia already renders those pages.
>
> **Who it's for:** Laravel + Vue developers
>
> **Applies to:** Laravel 13 · Vue 3 · Sanctum

## The fix

```php
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](https://laravel-vuejs.space/vue-router-laravel-spa), is the client that calls it. Cookie auth for that SPA is the [Sanctum guide](https://laravel-vuejs.space/laravel-sanctum-vue-spa). 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

**Q: 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.

**Q: 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.
