withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { $middleware->append(CorsMiddleware::class); $middleware->alias([ 'auth.apikey' => ApiKeyMiddleware::class, 'swagger.auth' => CheckSwaggerAuth::class, 'permission' => CheckPermission::class, ]); }) ->withExceptions(function (Exceptions $exceptions) { // 이건 비워두세요 }) ->create(); // 🔥 핵심: create() 이후에 반드시 등록 $app->singleton(ExceptionHandler::class, Handler::class); return $app;