Error 500 Internal Server Error

GET https://agent.ws-thiele.de/api/projects/01a0bf6e-7534-7811-95ba-5a03539ef3c8/live-subscription

Exceptions

Unable to create authorization cookie for a hub on the different second-level domain "localhost".

Exception

Symfony\Component\Mercure\Exception\ RuntimeException

  1. if ($currentDomain === $cookieDomain || str_ends_with($cookieDomain, $target)) {
  2. return $target;
  3. }
  4. }
  5. throw new RuntimeException(\sprintf('Unable to create authorization cookie for a hub on the different second-level domain "%s".', $cookieDomain));
  6. }
  7. private function updateCookies(Request $request, ?string $hub, Cookie $cookie): void
  8. {
  9. $hub = (string) $hub;
in vendor/symfony/mercure/src/Authorization.php -> getCookieDomain (line 121)
  1. if (!$cookieLifetime instanceof \DateTimeInterface && 0 !== $cookieLifetime) {
  2. $cookieLifetime = new \DateTimeImmutable("+{$cookieLifetime} seconds");
  3. }
  4. $path = $urlComponents['path'] ?? '/';
  5. $domain = $this->getCookieDomain($request, $urlComponents);
  6. $secure = 'http' !== strtolower($urlComponents['scheme'] ?? 'https');
  7. return Cookie::create(
  8. $this->getCookieName($hubInstance, $secure),
  9. $token,
  1. * @param array<string, mixed> $additionalClaims an array of additional claims for the JWT
  2. * @param string|null $hub the hub to generate the cookie for
  3. */
  4. public function setCookie(Request $request, array|string|null $grants = [], string|array|null $publish = null, array $additionalClaims = [], ?string $hub = null): void
  5. {
  6. $this->updateCookies($request, $hub, $this->createCookie($request, $grants, $publish, $additionalClaims, $hub));
  7. }
  8. /**
  9. * Clears the subscriber authorization cookie for the given hub.
  10. *
Authorization->setCookie(object(Request), array('https://agent-control.local/projects/01a0bf6e-7534-7811-95ba-5a03539ef3c8'), null, array('exp' => object(DatePoint))) in src/Project/UI/Http/LiveSubscriptionController.php (line 42)
  1. #[IsGranted(ProjectPermission::View->value, subject: 'project', statusCode: Response::HTTP_NOT_FOUND)]
  2. public function __invoke(Project $project, Request $request, Authorization $mercureAuthorization): JsonResponse
  3. {
  4. $topic = LiveUpdateTopic::project($project->getId());
  5. $expiresAt = $this->clock->now()->modify(\sprintf('+%d seconds', self::GRANT_SECONDS));
  6. $mercureAuthorization->setCookie($request, [$topic], additionalClaims: ['exp' => $expiresAt]);
  7. return new JsonResponse(
  8. ['topic' => $topic, 'hubUrl' => $this->hub->getPublicUrl(), 'expiresAt' => $expiresAt->format(\DATE_ATOM)],
  9. Response::HTTP_OK,
  10. ['Cache-Control' => 'no-store, private'],
  1. $this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
  2. $controller = $event->getController();
  3. $arguments = $event->getArguments();
  4. // call controller
  5. $response = $controller(...$arguments);
  6. // view
  7. if (!$response instanceof Response) {
  8. $event = new ViewEvent($this, $request, $type, $response, $controllerMetadata);
  9. $this->dispatcher->dispatch($event, KernelEvents::VIEW);
  1. $request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
  2. $this->requestStack->push($request);
  3. $response = null;
  4. try {
  5. return $response = $this->handleRaw($request, $type, $controllerMetadata);
  6. } catch (\Throwable $e) {
  7. if ($e instanceof \Error && !$this->handleAllThrowables) {
  8. throw $e;
  9. }
  1. if (!$this->handlingHttpCache) {
  2. $this->resetServices = true;
  3. }
  4. try {
  5. return $this->getHttpKernel()->handle($request, $type, $catch);
  6. } finally {
  7. --$this->requestStackSize;
  8. }
  9. }
  1. ) {
  2. }
  3. public function run(): int
  4. {
  5. $response = $this->kernel->handle($this->request);
  6. $response->send(false);
  7. if (\function_exists('fastcgi_finish_request') && !$this->debug) {
  8. fastcgi_finish_request();
in vendor/autoload_runtime.php -> run (line 32)
  1. $app = $app(...$args);
  2. exit(
  3. $runtime
  4. ->getRunner($app)
  5. ->run()
  6. );
require_once('/app/vendor/autoload_runtime.php') in public/index.php (line 7)
  1. declare(strict_types=1);
  2. use App\Kernel;
  3. require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  4. return static fn (array $context): Kernel => new Kernel(
  5. is_string($context['APP_ENV'] ?? null) ? $context['APP_ENV'] : 'prod',
  6. filter_var($context['APP_DEBUG'] ?? false, FILTER_VALIDATE_BOOL),
  7. );

Logs

Level Channel Message
INFO 17:44:28 request Matched route "_profiler".
{
    "route": "_profiler",
    "route_parameters": {
        "_route": "_profiler",
        "_controller": "web_profiler.controller.profiler::panelAction",
        "token": "8a7b3f"
    },
    "request_uri": "https://agent.ws-thiele.de/_profiler/8a7b3f",
    "method": "GET"
}

Stack Trace

RuntimeException
Symfony\Component\Mercure\Exception\RuntimeException:
Unable to create authorization cookie for a hub on the different second-level domain "localhost".

  at vendor/symfony/mercure/src/Authorization.php:205
  at Symfony\Component\Mercure\Authorization->getCookieDomain(object(Request), array('scheme' => 'http', 'host' => 'localhost', 'port' => 8088, 'path' => '/.well-known/mercure'))
     (vendor/symfony/mercure/src/Authorization.php:121)
  at Symfony\Component\Mercure\Authorization->createCookie(object(Request), array(object(Grant)), null, array('exp' => object(DatePoint)), null)
     (vendor/symfony/mercure/src/Authorization.php:57)
  at Symfony\Component\Mercure\Authorization->setCookie(object(Request), array('https://agent-control.local/projects/01a0bf6e-7534-7811-95ba-5a03539ef3c8'), null, array('exp' => object(DatePoint)))
     (src/Project/UI/Http/LiveSubscriptionController.php:42)
  at App\Project\UI\Http\LiveSubscriptionController->__invoke(object(Project), object(Request), object(Authorization))
     (vendor/symfony/http-kernel/HttpKernel.php:188)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1, object(ControllerArgumentsMetadata))
     (vendor/symfony/http-kernel/HttpKernel.php:79)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:143)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:34)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:32)
  at require_once('/app/vendor/autoload_runtime.php')
     (public/index.php:7)