Skip to content

Commit bcc5fab

Browse files
committed
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 (cherry picked from commit f3a9233)
1 parent 4595ca6 commit bcc5fab

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/angular/ssr/src/routes/ng-routes.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,18 @@ async function* traverseRoutesConfig(options: {
155155
} = route;
156156
const currentRoutePath = joinUrlParts(parentRoute, path);
157157

158-
if (matcher) {
159-
yield {
160-
error: `The route '${stripLeadingSlash(currentRoutePath)}' uses a route matcher which is not supported.`,
161-
};
162-
163-
continue;
164-
}
165-
166158
// Get route metadata from the server config route tree, if available
167159
let matchedMetaData: ServerConfigRouteTreeNodeMetadata | undefined;
168160
if (serverConfigRouteTree) {
161+
if (matcher) {
162+
// Only issue this error when SSR routing is used.
163+
yield {
164+
error: `The route '${stripLeadingSlash(currentRoutePath)}' uses a route matcher that is not supported.`,
165+
};
166+
167+
continue;
168+
}
169+
169170
matchedMetaData = serverConfigRouteTree.match(currentRoutePath);
170171
if (!matchedMetaData) {
171172
yield {

0 commit comments

Comments
 (0)