Hi there,
I’ve been banging my head against the wall trying to figure out why my Angular app is automatically redirecting to root after momentarily visiting the correct redirectUri upon a successful login.
The flow I have is fairly simple; when a user asks to login, I record the current path in local storage before calling this.authService.loginWithRedirect(). I have my callback URL set to /callback
, and a simple CallbackComponent routed to /callback:
@Component({
selector: 'app-callback',
templateUrl: './callback.component.html',
styleUrls: ['./callback.component.scss']
})
export class CallbackComponent implements OnInit {
constructor() { }
ngOnInit(): void {
console.log("In CallbackComponent");
}
}
After a successful login, however, Auth0 correctly redirects to “/callback” (and prints the console log), but then several milliseconds later the app navigates to “/” no matter what I try. I found this issue that looks to be very similar, but no resolution was posted: Redirect URI problem with Auth0-spa-js and Angular. Any thoughts on what might be going on?
For reference, here is a simplified version of my app-routing.module.ts
:
export const routes: Routes = [
{ path: 'callback', component: CallbackComponent },
{ path: '', component: HomePageComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
SDK: @auth0/auth0-angular (v1.2.0)
Angular v9.1.12
Node v15.2.1