app/Providers/RouteServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define the routes for the application.
*/
public function map(): void
{
Route::prefix('api')->middleware('api')->namespace($this->namespace)->group(base_path('routes/api.php'));
Route::middleware('web')->namespace($this->namespace)->group(base_path('routes/web.php'));
}
}