@@ -289,15 +289,22 @@ private function getSymfonyControllerFqcn(Request $request): ?string
289289 {
290290 $ routeName = $ request ->query ->get (EA ::ROUTE_NAME );
291291 $ routeParams = $ request ->query ->all ()[EA ::ROUTE_PARAMS ] ?? [];
292- // the "relative path" URL type is needed to be compatible with applications
293- // running behind a proxy under a permanent subpath prefix (AKA sub-folder,
294- // sub-url or sub-path - using the HTTP header x-forwarded-prefix)
295- $ url = $ this ->urlGenerator ->generate ($ routeName , $ routeParams , UrlGeneratorInterface::RELATIVE_PATH );
292+ $ url = $ this ->urlGenerator ->generate ($ routeName , $ routeParams , UrlGeneratorInterface::ABSOLUTE_PATH );
296293
297294 $ newRequest = $ request ->duplicate ();
298295 $ newRequest ->attributes ->remove ('_controller ' );
299296 $ newRequest ->attributes ->set ('_route ' , $ routeName );
300297 $ newRequest ->attributes ->add ($ routeParams );
298+
299+ // If the application is running behind a proxy under a permanent
300+ // subpath prefix (AKA sub-folder, sub-url or sub-path) using the HTTP
301+ // header x-forwarded-prefix, the URL is generated with
302+ // that prefix. We need to remove it before we can match it.
303+ $ basePath = $ request ->getBasePath ();
304+ if ('' !== $ request ->getBasePath () && str_starts_with ($ url , $ basePath )) {
305+ $ url = mb_substr ($ url , mb_strlen ($ basePath ));
306+ }
307+
301308 $ newRequest ->server ->set ('REQUEST_URI ' , $ url );
302309
303310 $ parameters = $ this ->requestMatcher ->matchRequest ($ newRequest );
0 commit comments