You could replace it: $apiHelperService->serverUrl($image->getPath())
We could then probably use that: $this->getRequest()->getSchemeAndHttpHost(); inside the serverUrl method in the ApiHelper.