diff --git a/app/controllers/general.php b/app/controllers/general.php index 83c19c359b..40a0751174 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -1416,7 +1416,12 @@ Http::error() ->addHeader('Pragma', 'no-cache') ->setStatusCode($code); - $template = $error->getView() ?? (($route) ? $route->getLabel('error', null) : null); + $template = $error->getView(); + + // SDKs send `accept: text/html` to these routes too, so only non-SDK requests get the error page + if ($template === null && $route && $request->getHeaderLine('x-sdk-name') === '') { + $template = $route->getLabel('error', null); + } // TODO: Ideally use group 'api' here, but all wildcard routes seem to have 'api' at the moment if (empty($route) || !\str_starts_with($route->getPath(), '/v1')) {