api: Can't group routes using different prefixes

Q A
Bug? no
New Feature? no
Framework Laravel
Framework version 5.x.y
Package version 1.x.y
PHP version 5.x.y

Actual Behaviour

I’m trying to group different route groups with different prefixes, but in the end only one prefix group is working.

Expected Behaviour

$api = app('Dingo\Api\Routing\Router');

$api->group(['version' => 'v1', 'prefix' => 'auth', 'domain' => env('APP_DOMAIN'), 'namespace' => 'App\\Http\\Controllers'], function($api) {

    $api->version('v1', ['middleware' => ['throttle:40', 'api']], function ($api) {

        $api->post('login', 'AuthController@login');
        ... Routes...
     });
});

$api->group(['version' => 'v1', 'prefix' => 'main', 'domain' => env('APP_DOMAIN'), 'namespace' => 'App\\Http\\Controllers'], function($api) {

    $api->version('v1', ['middleware' => ['throttle:40', 'api']], function ($api) {

        $api->post('/cables',                           'CablesController@postCreate');
        ... Routes...
     });
});

How to solve this ? I need exactly this kind of solution, using same domain and different route groups defined by prefixes. Thanks

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@hxdef2517 Just configure the API_DOMAIN as the error message implies. Note to leave out the “http://”.