Я нашел решение сам. Начиная с TYPO3 9.5, обработка по умолчанию не найденной страницы может быть переопределена в конфигурации сайта:
errorHandling:
-
errorCode: 404
errorHandler: PHP
errorPhpClassFQCN: Vendor\MyExt\PageErrorHandler\PageNotFoundHandler
И в EXT: MyExt / Classes / PageErrorHandler / PageNotFoundHandler.php:
<?php
namespace Vendor\MyExt\PageErrorHandler;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
/**
* Class PageNotFoundHandler
*/
class PageNotFoundHandler implements PageErrorHandlerInterface
{
/**
* Handle page error
*
* @param ServerRequestInterface $request
* @param string $message
* @param array $reasons
* @return ResponseInterface
*/
public function handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
{
$response = new Response(404, ['Content-Type' => 'application/json'], '{"error":"Not found"}');
return $response;
}
}