I am using auth0 for authentication. In my angular app I have an AuthGuard to prevent routing to the angular app during authentication with auth0. During the authentication the url looks like this
https://www.examplesite.com/#access_token=jlfdsfhWboAhvlRhbZt&expires_in=86400&id_token=aeryJ0eXAfsiOiJ..&token_type=Bearer&state=16d15855-0827-4189-bc34-26b981d578bb
The app contains the following routes
export const ROUTES: Routes = [
{ path: '', loadChildren: './home/home.module#HomeModule', canActivate: [AuthGuard] },
{ path: '**', redirectTo: '/' },
];
Here is the AuthGuard:
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private router: Router, private location: Location, private authService: AuthService) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
if (route.fragment && route.fragment.startsWith('access_token')) {
return false;
}
return true;
}
}
This works fine on localhost. The AccessToken path appears and after it disappears the app is loading successfully.
But it does not work on the published server. It shows the accesstoken path and it disappears the app isn't loaded.
In the console I get this warning #access_token=rfsdf...&expires_in=86400&id_token=rfafsdf...&token_type=Bearer&state=72e39d8b-7907-4fbb-88fb-1dd690622541:7 The key "" is not recognized and ignored.
Any idea why this works on localhost but not on the server?