Bug #93236
closedRequireJS Error at backend login
100%
Description
I need to add a JS lib to the backend (more precisely to the backend login) which worked fine in v10 - and works fine in v11 after logging into the backend.
On login screen I can see an error 500 in the browser console (coming from requirejs-loader.js:67), which is the result of
Symfony\Component\Routing\Exception\ResourceNotFoundException No routes found for "/ajax/core/requirejs&name=nameOfTheLibToLoad".
As said, the error is gone when logged in to the backend and the file is loaded as required.
This is the code, which registers the lib.
$pageRenderer->addRequireJsConfiguration([
'shim' => [
'nameOfTheLibToLoad' => [
'exports' => 'nameOfTheLibToLoad'
]
],
'paths' => [
'nameOfTheLibToLoad' => PathUtility::getAbsoluteWebPath(
ExtensionManagementUtility::extPath(
'myext',
'Resources/Public/JavaScript/'
)
)
. 'filenameOfTheLibToLoadWithoutDotJs'
]
]);
This code works as expected (but fails due to the missing lib)
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Myext/FileWithoutDotJs');
Updated by Andreas Kienast almost 4 years ago
- Status changed from New to Needs Feedback
This seems to be fixed with #93227. Can you please check this with the latest master?
Updated by Kevin Appelt almost 4 years ago
On current master the problem changes a little bit but is still present.
What i cann see in the browser console:
ajax/core/requirejs?name=nameOfTheLibToLoad:1 Failed to load resource: the server responded with a status of 404 ()
So it is not an error 500, but a 404 now.
Unchanged:
- problem is gone as soon as the user is logged in
Updated by Benjamin Franzke almost 4 years ago
Where do you invoke $pageRenderer->addRequireJsConfiguration(…)
?
Which hook/event are you using?
Updated by Riccardo De Contardi over 3 years ago
- Category set to Backend JavaScript
Updated by Benni Mack about 3 years ago
- Target version changed from 11.4 to 11 LTS
Updated by Kevin Appelt about 3 years ago
I've prepared an extension to check the issue: https://github.com/kevin-appelt/TrianglifyBackground
In TYPO3 Version 10 everything is fine.
In TYPO3 Version 11 the code does not work.
Updated by Gerrit Code Review about 3 years ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71389
Updated by Benjamin Franzke about 3 years ago
Thanks for the example extension.
So the issue basically happens because you're adding the configuration in ext_localconf.php in TYPO3 v10, but via PageRenderer render-preProcess in TYPO3 v11.
So two completely different codepaths
Sure, you do this because TYPO3 core does the same for rte_ckeditor and t3editor since #92848.
Now, the issue is that since RequireJS configuration is loaded ondemand (with a separate AJAX request) at the TYPO3 backend login screen for security reasons (see #83855). In that context the hook is never executed (neither in v10 nor in v11)
And because of that it would have failed in TYPO3 v10 as well, if you would have used the hook there.
Now, what is the difference between rte_ckeditor and t3editor and your extension?
These core extensions don't require their configuration to be available during backend login, therefore the usage of the render-preProcess
hook is ok(ish), while not perfect.
But render-preProcess
has never been an explicit post-configuration API.
I'm not sure whether we really want to officially support that – if so https://review.typo3.org/c/Packages/TYPO3.CMS/+/71389 would solve this issue – or if we rather introduce a new Event that allows to modify requirejs configuration and use that in core as well.
Updated by Gerrit Code Review about 3 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395
Updated by Benjamin Franzke about 3 years ago
An alternative would be to avoid the hook and rather fix addRequireJsConfiguration to work without conditions in ext_localconf.php
Implementation would be as follows:
71395: [BUGFIX] Fix PageRenderer->addRequireJsConfiguration from ext_localconf | https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395
Adaption for the demo extension:
https://github.com/bnf/TrianglifyBackground/commit/no-hook
Updated by Gerrit Code Review about 3 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395
Updated by Gerrit Code Review about 3 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395
Updated by Gerrit Code Review about 3 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395
Updated by Gerrit Code Review about 3 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71395
Updated by Benjamin Franzke about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset afada335c0a3fb66f80ea34ac493379e9fa6c63b.