#96588URI to backend module can only be generated from BE context
Description
It seems not possible to create absolute links from the frontend to a certain backend module, is it?
Use case might be a mail triggered by a frontend user action sent to an admin, so they log into the TYPO3 backend to check that users generated input.
I’ve tried both ways, fluid viewhelper and php, but the resulting URI is always missing the /typo3/ slug!
fluid viewhelper:
<f:be.link route="web_layout">click me</f:be.link>
php:
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uri = $uriBuilder->buildUriFromRoute('web_layout', ['id' => $pageId]);
Reviews 1
History 7
-
Georg Ringer commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2022-02-15T07:38:18+00:00" > 02/15/22, 07:38 </span> -
Philipp Kitzberger commented <span data-processor="relativetime" data-value="2022-02-15T09:13:04+00:00" > 02/15/22, 09:13 </span>
I’ve tried it with TYPO3 version 11.5.6 and all of the 3rd parameters of that method. Here’s the results:
UriBuilder::ABSOLUTE_PATH (which is the default)
$urlToBackend = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 700], UriBuilder::ABSOLUTE_PATH);=> /typo3/module/web/layout?token=23a6b3c1eebccd55516c9b594a53c939dac047c7&id=700
UriBuilder::ABSOLUTE_URL
$urlToBackend = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 700], UriBuilder::ABSOLUTE_URL);=> http://my.domain.dev:8080/module/web/layout?token=23a6b3c1eebccd55516c9b594a53c939dac047c7&id=700
UriBuilder::SHAREABLE_URL
$urlToBackend = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 700], UriBuilder::SHAREABLE_URL);=> http://my.domain.dev:8080/module/web/layout?id=700
Only ABSOLUTE_PATH seems to be prepending the backend segment
/typo3/;-( -
Philipp Kitzberger commented <span data-processor="relativetime" data-value="2022-02-15T09:23:57+00:00" > 02/15/22, 09:23 </span>
Within a CLI task (Symfony Console Command) it’s like this:
**UriBuilder::ABSOLUTE_PATH**
=> /typo3/module/web/layout?token=79dfeab622fc864f653bc331c9b5dddae1a53373&id=700**UriBuilder::ABSOLUTE_URL**
=> http://bin/module/web/layout?token=2db3ed68adb23c7b443554f6f7eba659331c1792&id=700**UriBuilder::SHAREABLE_URL**
=> http://bin/module/web/layout?id=700 -
B. Kausch commented <span data-processor="relativetime" data-value="2022-06-15T09:14:13+00:00" > 06/15/22, 09:14 </span>
This is clearly a bug. You can’t build shareable backend urls in frontend context (which is a perfectly possible case). The problem is this line: https://forge.typo3.org/projects/typo3cms-core/repository/1749/revisions/master/entry/typo3/sysext/backend/Classes/Routing/UriBuilder.php#L182
-
Riccardo De Contardi changed status
Needs FeedbackNew <span data-processor="relativetime" data-value="2022-06-18T07:28:12+00:00" > 06/18/22, 07:28 </span> -
Benni Mack commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2022-11-07T22:20:24+00:00" > 11/07/22, 22:20 </span>Hey,
yes. this was not possible until now, as we’ve been having a hard time with all the GeneralUtility::getIndpEnv() calls.
In v12, we’ve overcome this with a proper “BackendEntryPointResolver” class, see https://review.typo3.org/c/Packages/TYPO3.CMS/+/75620 – can you recheck?
-
Benni Mack commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2025-03-25T09:00:02+00:00" > 03/25/25, 09:00 </span>Hey Philipp,
closing this due to lack of feedback and IMHO resolved properly in v12.
just had the following in a frontend extbase controller
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uri = $uriBuilder->buildUriFromRoute('web_layout', ['id' => 1]); DebuggerUtility::var_dump((string)$uri);die;and the response was
tested in latest 11 branch, can you recheck?