mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
1 file changed
+6
-1
@@ -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')) {
|
||||
|
||||
Reference in new issue
Block a user