diff --git a/src/HandleCors.php b/src/HandleCors.php index e3bb570..7790b1b 100644 --- a/src/HandleCors.php +++ b/src/HandleCors.php @@ -48,7 +48,7 @@ public function handle($request, Closure $next) } // Add the headers on the Request Handled event as fallback in case of exceptions - if ($this->container->bound('events')) { + if (class_exists(RequestHandled::class) && $this->container->bound('events')) { $this->container->make('events')->listen(RequestHandled::class, function (RequestHandled $event) { $this->addHeaders($event->request, $event->response); });