Prod mode Error: Cannot match any routes. URL Segment: 'connect/authorize'
See original GitHub issueFirst 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:
- Created 4 years ago
- Comments:5
Top GitHub Comments
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.
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.