Merge pull request #13625 from appwrite/fix/html-error-negotiation

fix(errors): return JSON errors to SDK requests on redirect routes
This commit is contained in:
Harsh Mahajan authored and GitHub committed 2026-09-11 18:58:32 +05:30
commit 67bb172ef0
1 file changed
+6 -1
+6 -1
View File
@@ -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')) {