Issue Bug Resolved

#107636Flaws with importmap in PageRenderer:setApplyNonceHint() in the frontend context

Oliver Hader 10/09/25, 10:24 updated 11/11/26, 15:20

Description

In the frontend context, the lit-nonce is added using $pageRenderer->setApplyNonceHint(true);

In TYPO3 v13 and since issue #101297 was merged, the frontend output contains the full importmap (which is not applied when having CSP activated and not allowing unsafe-inline, since the nonce value for the import map was explicitly omitted in the frontend context in PageRenderer::renderMainJavaScriptLibraries).

By calling $pageRenderer->setApplyNonceHint(true); for the frontend context the following happens:
  • in TYPO3\CMS\Core\Page\JavaScriptRenderer::renderImportMap the instructionsWithItems hold the litNonce assignment
  • this requires typo3/core/java-script-item-handler.js to be loaded
  • this resolves and adds the imports for typo3/core/* packages

However, all this does not seem to be necessary, since in the frontend PageRenderer still uses Object.assign for assigning litNonce.

<script type="importmap">{"imports":{"@typo3/core/":"/_assets/1ee1d3e909b58d32e30dcea666dd3224/JavaScript/",
"autosize":"/_assets/1ee1d3e909b58d32e30dcea666dd3224/JavaScript/Contrib/autosize.js?bust=1760004735", ...</script>

<script nonce="oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ">
Object.assign(globalThis, {"litNonce":"oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ"})</script>

<script src="/_assets/af46f1853e4e259cbb8ebcb816eb0403/JavaScript/elements.js?1759920968" type="module" async="1" nonce="oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ"></script>
<script src="/_assets/af46f1853e4e259cbb8ebcb816eb0403/JavaScript/globals.js?1759920968" type="module" async="1" nonce="oyplKMHWtccMJ-ut1hYjggWM0Hcu_m-c3mt1n30NBl7P-e3quHiPBQ"></script>

Reviews 2

History 35

  1. Oliver Hader changed subject Flaws with PageRenderer:setApplyNonceHint() in the frontend context Flaws with importmap in PageRenderer:setApplyNonceHint() in the frontend context <span data-processor="relativetime" data-value="2025-10-13T07:20:04+00:00" > 10/13/25, 07:20 </span>

  2. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-11-11T15:20:13+00:00" > 11/11/26, 15:20 </span>

    Applied in changeset commit:811d4cca0da4297a96f7730d95b977bad3106c8d.