Mark
Mark

Reputation: 5612

How to determine where an Angular route redirect originates?

I have an Angular 6 SPA. Periodically, the app performs an action behind the scenes in an iframe (to silently refresh an OAuth token). Each time my app does this, it redirects to the "/" route. This is undesirable behavior for the reason that if a user is in the middle of completing a form, he will lose his form and be redirected.

I believe that the redirect is happening as a result of something in my code; perhaps a Guard. Is there good a way to determine the source of a route redirect in Angular?

Upvotes: 1

Views: 1095

Answers (2)

n1cK
n1cK

Reputation: 358

If you use a Standalone component setup for your Angular App, it's in

main.ts:

provideRouter(APP_ROUTES, withDebugTracing()),

Upvotes: 0

Tony
Tony

Reputation: 20082

You can enable debug mode for rouuting in angular using enableTracing

RouterModule.forRoot(routes, { enableTracing: true })

You will see there is a lot of event running in the app when using routing. So you can do debug more easily. Hope that help.

enter image description here

Upvotes: 3

Related Questions