- Site set Vitecset: new bool setting vitec.ssr.enabled (default off, backend switch under Site Management > Settings > VITEC Settings) - SsrFlagService derives var/vitec-ssr-on.flag from the setting; SyncSsrFlag middleware (frontend + backend) re-syncs per request because TYPO3 v14 fires no event on site settings save; vitec:ssr-flag CLI command for status/--sync - public/.htaccess: flag-gated block proxies page requests [P] to https://vitec-ssr.evomedien.de (mod_proxy incl. https target verified on this host 2026-11-09), same exclusions as the SPA fallback block; completely inert while the flag file is absent - Emergency off without TYPO3: delete var/vitec-ssr-on.flag - Tested end to end: flag on -> pages proxied to VPS Caddy (502 while the SSR node is not deployed yet), /_json untouched; flag off -> SPA shell exactly as before Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Evomedien\Vitec\Middleware;
|
|
|
|
use Evomedien\Vitec\Service\SsrFlagService;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Psr\Http\Server\MiddlewareInterface;
|
|
use Psr\Http\Server\RequestHandlerInterface;
|
|
|
|
/**
|
|
* Self-healing sync of the SSR routing flag (see SsrFlagService).
|
|
*
|
|
* Registered for BOTH stacks: backend, so flipping the Site Set switch
|
|
* takes effect with the very next backend request (the module reload
|
|
* right after saving), and frontend, so /_json traffic repairs the flag
|
|
* even if nobody is logged into the backend. When flag and setting
|
|
* agree - the normal case - this costs a single file_exists() per
|
|
* request.
|
|
*/
|
|
final class SyncSsrFlag implements MiddlewareInterface
|
|
{
|
|
public function __construct(private readonly SsrFlagService $ssrFlagService)
|
|
{
|
|
}
|
|
|
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
|
{
|
|
$this->ssrFlagService->syncQuietly();
|
|
return $handler->handle($request);
|
|
}
|
|
}
|