question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use pathMatch without redirect or component, etc anymore regression

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

Yes

Description

After updating to Angular 14, I cannot run my project anymore because of missing element in my routing.

{ path: 'message', component: MessagePageComponent, children: [
   { path: '', pathMatch: 'full', canActivate: [AutoSelectGuard] },
   { path: 'settings', component: MessageSettingsComponent, canActivate: [GroupSelectGuard], children: [
      . . .
    ])
   { path: 'summary', component: MessageSummaryComponent, canActivate: [GroupSelectGuard],

Where on the second line the [AutoSelectGuard], redirects to any sub page, depending on the last time you visited that sub page.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

core.mjs:6412 ERROR Error: Invalid configuration of route 'infotainment//message/'. One of the following must be provided: component, loadComponent, redirectTo, children or loadChildren

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.0.1
Node: 16.13.0
Package Manager: npm 8.3.0
OS: win32 x64

Anything else?

After adding “redirectTo:‘settings’” to that second line I got following exception:

core.mjs:6412 ERROR Error: Invalid configuration of route ‘infotainment//message/’: redirectTo and canActivate cannot be used together. Redirects happen before activation so canActivate will never be executed.

So Angular knows I’m using an canActivate guard and it’s mutual exclusive too.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
atscottcommented, Jun 10, 2022

The configuration was never intended to be allowed. Before v14, Lazy loaded configs we’re not validated but now they are. This change is listed in the v14 breaking changes.

The use case you’re describing is a feature gap in the API, which is a duplicate of https://github.com/angular/angular/issues/13373

0reactions
angular-automatic-lock-bot[bot]commented, Jul 11, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular route: pathMatch='full', when to NOT use?
With basic research, I understood, '' will match with other routes "always" and so that might create cyclic redirection if pathMatch: 'full' is ......
Read more >
Error: Cannot match any routes in Angular 4 - Stack Overflow
pathMatch is used for redirects, which means that if you have a pathMatch property in your route, you should have a redirectTo as...
Read more >
The Ultimate Guide to Redirects: URL Redirections Explained
Redirects send users & search engines from one URL to another. Find out how to use each type here.
Read more >
Angular 2 Tutorial - 37 - Redirects and pathMatch - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >
Redirections in HTTP - MDN Web Docs - Mozilla
URL redirection, also known as URL forwarding, is a technique to give more ... They imply that the original URL should no longer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found