Skip to content

Commit

Permalink
fix(@angular/ssr): prevent route matcher error when SSR routing is no…
Browse files Browse the repository at this point in the history
…t 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

(cherry picked from commit f3a9233)
  • Loading branch information
alan-agius4 committed Jan 20, 2025
1 parent 4595ca6 commit bcc5fab
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/angular/ssr/src/routes/ng-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bcc5fab

Please sign in to comment.