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
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)
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community