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.

Prod mode Error: Cannot match any routes. URL Segment: 'connect/authorize'

See original GitHub issue

First off, I apologize if I’m in the wrong place, so thanks for your patience.

I’m using .NET Core 2.2 with Identity Server4 with Angular 7 (CLI) and v5.0.2 of this library and everything works great in development mode. I hit a login button, I get redirected to a static page on the same server (the angular SPA and the ID server are currently one and the same), I log in, and the site redirects me back to my SPA and angular takes over and everything is good 👍 .

When I build in production mode, though (and I’m not sure where the disconnect is, which is why I’m posting), when I go to login, I get the following error in the console and my MVC controller for the login page is never hit (it should be):

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'connect/authorize'
Error: Cannot match any routes. URL Segment: 'connect/authorize'

I receive this error because I do not currently have a fallback route setup. If I setup a fall back route, then the error goes away but I’m also never actually directed to the login page; the app just reloads itself and does not navigate to the static site page.

The last piece of code that I see the app hitting before refreshing is this.oauthService.initImplicitFlow();, then the app reloads with something like this in the request URI: connect/authorize?response_type=id_token%20token&client_id=spaweb&state=pX1XiyN03w2yic3yGDDkMdnGQyfXJivUh9EwOY5G&redirect_uri=https%3A%2F%2Flocalhost%3A44350%2Fhome&scope=spaweb%20openid%20profile&nonce=pX1XiyN03w2yic3yGDDkMdnGQyfXJivUh9EwOY5G, and app.component starts doing its normal loading process. It appears that Angular is refusing to let the server handle the request at all, but I’m at a loss as to how that can happen.

Any thoughts on what could be going on here that I’m missing? I’d greatly appreciate any pointers you could give!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
christopher192commented, Jan 13, 2022

Hi, have you solved ur issue? I have tested both development and production mode, it is working fine. Once I publish and deploy it to IIS with the folder name “WorldCities2” then modify the base href from / to /WorldCities2/. The error “ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ‘worldcities2/Home’” occur. worldcities2/Identity/Account/Register and worldcities2/Identity/Account/Login also working just fine.

1reaction
FabianBGcommented, Mar 12, 2020

I faced the same issue I changed the routing to hash, and tried all the possibles solutions on https://github.com/angular/angular-cli/issues/6757, in my case I have the routes on a separated file called routes, and in the router module I did the import and some clean. In dev mode all works fine but the issue comes in prod mode, I think it has to be for the aot compilation it compiles the routes before the import of the routes so the main router has no routes, I solver putting all my routes inside the router module and it works for dev and prod builds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot match any routes. URL Segment - Stack Overflow
I updated the plunker with the latest angular 2.4.1 version: PLUNKER. The sample is running without an empty path right now.
Read more >
Router and multiples outlets - Google Groups
The error is: EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'planos' Error: Cannot match any routes.
Read more >
Unable to Get Callback URL to work in Angular 5
ERROR Error : Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'access_token' Error: Cannot match any routes.
Read more >
Error: Cannot match any routes - Nishu Goel - Medium
When the path URL gets matched, and it looks forward to displaying the corresponding component, it needs to look for a router-outlet component...
Read more >
Angular OpenID Connect Implicit Flow with IdentityServer4
The RedirectUris must match the redirect_uri URL used for the client ... Path.HasValue && null != angularRoutes.FirstOrDefault(.
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