Get relative url to published Node Document

Hi everyone,

hope some one can help me by this task (Neos 4.3).
I’m building an AWS CloudFront Cache Invalidator and need the relativ url to the published node document (for live workspace).
I have the signal with the node and the workspace working, the invalidation for CloudFront but im struggling with the getting the relative path.

    public function afterNodePublishing($node, Workspace $targetWorkspace): void
    $workspaceName = $targetWorkspace->getName();

    if ($workspaceName !== 'live') {

    $contentContext = $this->contextFactory->create(array(
        'workspaceName' => 'live',
        'currentSite' => $node->getContext()->getCurrentSite()

    $liveNode = (new FlowQuery(array($node)))->context(array('workspaceName' => 'live'))->get(0);

    $controllerContext = new ControllerContext(
        new Response(),
        new Arguments(array()),

    //@TODO: Render relative URL to pass it to cloudfront - currently not working
    $relativeHttpNodeUrl = $this->linkingService->createNodeUri(

    if (empty($relativeHttpNodeUrl)){

Any hints what I’m doing wrong?

As soon as it is working, I’ll make it a public package. :slight_smile:

Thank you!

@kapale can you elaborate what doesn’t work? That would help to debug this :slight_smile:

@kapale OK, I recreated the scenario and it didn’t work for a couple of reasons:

  1. When the nodePublished signal is triggered, the node might not be persisted yet
  2. The published node is mostly not the Document Node so you need to fetch the closest Neos.Neos:Document node first.

This seems to work:

@kapale can we mark this topic as [SOLVED]?

@kapale FYI I moved the post to the right category. If the response above helped, please mark it as “solution” so that others with the same issue can find it more easily.
Otherwise let us know if this still doesn’t work