Reputation: 131
when I used angular 5.2.11 with @azure/msal-angular 0.1.1, I got the following error message after I completed the login process and back to one of my route.
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'id_token'
there are a few posts to say adding <base href="/">
which I did, but still not help.
the following is my package.json. the whole project was created from vs2017 (15.8.2)->angular template.
{
"name": "WebApplication1",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
"build:ssr": "npm run build -- --app=ssr --output-hashing=media",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.11",
"@angular/common": "^5.2.11",
"@angular/compiler": "^5.2.11",
"@angular/core": "^5.2.11",
"@angular/forms": "^5.2.11",
"@angular/http": "^5.2.11",
"@angular/platform-browser": "^5.2.11",
"@angular/platform-browser-dynamic": "^5.2.11",
"@angular/platform-server": "^5.2.11",
"@angular/router": "^5.2.11",
"@azure/msal-angular": "^0.1.1",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.2.11",
"@angular/language-service": "^5.2.11",
"@types/jasmine": "^2.8.8",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.117",
"codelyzer": "^4.4.4",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.5",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
},
"optionalDependencies": {
"node-sass": "^4.9.0"
}
}
Upvotes: 2
Views: 3411
Reputation: 357
For those coming here lately, this is updated for newer rxjs version (Code goes in app.component.ts)
ngOnInit() {
this.router.events.pipe(filter ((event: any) => event instanceof NavigationStart) ).subscribe( (data: NavigationStart) => {
if (data.url === '/id_token') {
let hash = window.location.hash;
console.log("hash is : " + hash);
this.router.navigate(['/']);
}
});
}
Upvotes: 1
Reputation: 541
I resolved this by putting below code in the app.routing.ts file
{
path: 'id_token',
redirectTo: 'path-you-want-to-redirect-to',
},
Also, if you want to have another workaround, you can use the below code in your app.component.ts file
ngOnInit() {
this.router.events.filter((event: any) => event instanceof NavigationStart)
.subscribe((data: NavigationStart) => {
if (data.url === '/id_token') {
this.hash = window.location.hash;
this.router.navigate(['path-you-want-to-navigate-to']);
}
});
}
I would suggest going with adding the route in the routing.ts file.
Upvotes: 4