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

zacarey's avatar

Duplicate api prefix in routes

I'm relatively new to Laravel Spark and I'm trying to create API routes for my application.

However, I'm having an issue with duplicate api prefixes in my routes. For instance, my login route is

/api/api/v1/login

And currently my route/api.php file looks syntactically correct

Route::group(['prefix' => 'api/v1'], function() { Route::post('login', 'Api\V1\Controllers\AuthController@login'); });

I'm guessing this is some type of config issue but I'm not sure. Any help is appreciated, thanks.

0 likes
3 replies
DarkRoast's avatar
Level 8

route/api.php routes already have the 'api' prefix set in Providers/RouteServiceProvider.php

1 like
zacarey's avatar

Thanks, that worked. Not sure why a fresh project would include a group 'api' prefix if that's set in Providers.

spekkionu's avatar

The api routes already have a prefix of api defined in the RouteServiceProvider so your group prefix only needs to be "v1".

Alternatively you can change the prefix in the service provider to add the version if that is the only version you have. Then you wouldn't need a group at all.

1 like

Please or to participate in this conversation.