getMethod()) { $response = Context::mustGet()->getResponse(); return $this->configResponse($response); } $response = $handler->handle($request); return $this->configResponse($response); } private function configResponse(ResponseInterface $response) { return $response ->withHeader('Access-Control-Allow-Origin', '*') ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization') ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS'); } }