Support the ongoing development of Laravel.io →
Configuration
Last updated 2 years ago.
0

Solved it this way:

protected function mapApiRoutes()
    {
        $callback = function ($router) {
            require base_path('routes/api.php');
        };

        //production
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'domain' => 'api.{domain}.{tld}'
        ], $callback);

        //test
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'domain' => 'apitest.{domain}.{tld}'
        ], $callback);        
    }

source: https://github.com/laravel/framework/issues/4017#issuecomment-39091856

Last updated 7 years ago.
0

UPDATE. This is NOT solved. Well, not if I want to use parameters from the URI. For instance,

Route::get(test/{id}, function($id) {
    return $id     //example (where domain is api.example.local)
});

If I keep the code as is, I would have to use the route like this,

Route::get(test/{id}, function($domain, $tld, $id) {
    return $id   //999 (where id = 999)
});
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.