Issue Bug New

#96077Workspace top bar won't work in multidomain setups

Christian Eßl 11/25/21, 13:20 updated 11/12/26, 10:53

Description

Status quo:
The new workspaces since TYPO3 10.4 uses a hook in the mechanism, that changes the preview urs generated from inside the backend. (For example if you are currently in the workspace and use the “View webpage” button in the Page/List module)
The workspace preview urls work in a way that includes a workspace bar at the top of the previewed page and the frontend page itself inside an iframe.

Problem:
This will not work in multidomain setups, because an active backend login is required and the session is locked to the domain the user used when logged into the backend, not necessarily the same domain used for the frontend preview.
So in this case, another configurable option is required for multidomain setups.

There is already a solution in the core for generating preview urls that are token-based and don’t require an active backend login. (which is used by the workspaces module itself) If anyonse else has the problem, right now I am using this PreviewUrl hook for a multidomain setup:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass'][] =
    \Foobar\Hook\PreviewUrlHook::class;
class PreviewUrlHook
{
    public function postProcess($url, $uid)
    {
        $stmt = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getConnectionForTable('pages')
            ->select(['sys_language_uid'], 'pages', [
                'uid'      => $uid,
            ], [], [], 1);
        $page = $stmt->fetch();

        if ($GLOBALS['BE_USER']->workspace !== 0) {
            $url = GeneralUtility::makeInstance(PreviewUriBuilder::class)
                ->buildUriForPage((int)$uid, (int)$page['sys_language_uid']);
        }

        return $url;
    }
}

Of course no workspace bar at the top, but versioned pages can now be previewed by the user, if the domain is different to the backend login.

Reviews 1

History 4

  1. Lidia Demin commented <span data-processor="relativetime" data-value="2022-02-17T15:56:39+00:00" > 02/17/22, 15:56 </span>

    Can confirm this problem on TYPO3 10.4.22. Haven’t tested the hook yet, but thanks for sharing your solution!

  2. Lidia Demin commented <span data-processor="relativetime" data-value="2022-02-21T10:24:45+00:00" > 02/21/22, 10:24 </span>

    Thanks for the hook! Works fine in my multi-tree-multi-domain setup!

  3. Daniel Haupt commented <span data-processor="relativetime" data-value="2023-12-18T05:35:30+00:00" > 12/18/23, 05:35 </span>

    I can confirm this issue for TYPO3 v11.5.33.

    The hook is still working as a temporary solution.

  4. Thomas Wittich commented <span data-processor="relativetime" data-value="2026-11-12T10:53:05+00:00" > 11/12/26, 10:53 </span>

    Hi!

    Confirmed on TYPO3 13.4.37 (multi-site, backend on another domain than the site).
    Besides the missing backend session cookie on the site domain (→ frontend renders live, 404 for new pages), the frame is first blocked by the backend CSP: PreviewController (workspace_previewcontrols) does not extend frame-src with the frontend URL, unlike ViewModuleController::showAction(). The CSP violation report shows effective-directive: frame-src, blocked-uri: https://<site domain>, document-uri: /typo3/workspace/preview-control?id=….<br>Workaround: log in to the backend through the site’s domain.<br>Change <a href="https://review.typo3.org/c/97235" target="_blank" rel="noreferrer">https://review.typo3.org/c/97235</a> (#110664) addresses both parts (preview token + frame-src mutation) for main/14.3. Is a fix for 13.4 planned?</site>