Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Use http request for generating usage urls #235

Merged
merged 2 commits into from Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion Classes/Service/UsageDetailsService.php
Expand Up @@ -26,8 +26,10 @@
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
use Neos\ContentRepository\Exception\NodeConfigurationException;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Exception as FlowException;
use Neos\Flow\Http\Exception as HttpException;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\I18n\Translator;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
Expand Down Expand Up @@ -57,6 +59,12 @@ class UsageDetailsService
use CreateContentContextTrait;
use BackendUserTranslationTrait;

/**
* @Flow\Inject
* @var Bootstrap
*/
protected $bootstrap;

/**
* @Flow\Inject
* @var UserService
Expand Down Expand Up @@ -326,7 +334,14 @@ protected function usageIsAccessible(string $workspaceName): bool
*/
protected function buildNodeUri(?Site $site, NodeInterface $node): string
{
$serverRequest = ServerRequest::fromGlobals();
$requestHandler = $this->bootstrap->getActiveRequestHandler();

if ($requestHandler instanceof HttpRequestHandlerInterface) {
$serverRequest = $requestHandler->getHttpRequest();
} else {
$serverRequest = ServerRequest::fromGlobals();
}

$domain = $site ? $site->getPrimaryDomain() : null;

// Build the URI with the correct scheme and hostname for the node in the given site
Expand Down