serves the TYPO3 (headless JSON) response for . * * Part of the URL swap requested 2026-09-28: page URLs are for visitors * (the React app - the .htaccess SPA fallback of phase B), the JSON moves * under the /_json prefix. Apache cannot do the strip itself in a useful * way - TYPO3 routes by the original REQUEST_URI - so the prefix is * removed here, before site/page resolution; everything downstream sees * the plain path and behaves exactly as a direct request would. Same * pattern as SuccessStoryPathRewrite. The query string is untouched, so * /_json/?type=834 and the suggest page type work as before. * * Runs before the other vitec path middlewares: a front end that prefixes * ALL its calls may also send /_json/download/... or * /_json/api/vitec/form/... - after the strip those reach their middleware * unchanged, so both the prefixed and the direct form keep working. * * Exception-safe: any failure leaves the request untouched. */ final class JsonPrefixRewrite implements MiddlewareInterface { private const PREFIX = '/_json'; public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { try { $path = $request->getUri()->getPath(); if ($path === self::PREFIX || str_starts_with($path, self::PREFIX . '/')) { $stripped = substr($path, strlen(self::PREFIX)); $request = $request->withUri( $request->getUri()->withPath($stripped === '' || $stripped === '/' ? '/' : $stripped) ); } } catch (\Throwable) { // untouched request } return $handler->handle($request); } }