From 568211e7683e6eb83acf0b45f80e646e90a68d6b Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 20 Jan 2025 14:55:39 +0000 Subject: [PATCH] fix(@angular/ssr): prevent route matcher error when SSR routing is not used Although route matchers are not supported with the SSR Routing API, they still function with the legacy `CommonEngine`. Therefore, no error should be issued in this case. Closes #29420 --- packages/angular/ssr/src/routes/ng-routes.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/angular/ssr/src/routes/ng-routes.ts b/packages/angular/ssr/src/routes/ng-routes.ts index 137a14604b18..b0b8848569d5 100644 --- a/packages/angular/ssr/src/routes/ng-routes.ts +++ b/packages/angular/ssr/src/routes/ng-routes.ts @@ -155,17 +155,18 @@ async function* traverseRoutesConfig(options: { } = route; const currentRoutePath = joinUrlParts(parentRoute, path); - if (matcher) { - yield { - error: `The route '${stripLeadingSlash(currentRoutePath)}' uses a route matcher which is not supported.`, - }; - - continue; - } - // Get route metadata from the server config route tree, if available let matchedMetaData: ServerConfigRouteTreeNodeMetadata | undefined; if (serverConfigRouteTree) { + if (matcher) { + // Only issue this error when SSR routing is used. + yield { + error: `The route '${stripLeadingSlash(currentRoutePath)}' uses a route matcher that is not supported.`, + }; + + continue; + } + matchedMetaData = serverConfigRouteTree.match(currentRoutePath); if (!matchedMetaData) { yield {