Ionic 4 Angular 9 how to bypass particular route in the guard?

I have a guard that redirects the user to tabs page if user has been authenticated else redirects to home (login) page.

Now on a particular operation, my backend express server redirects the user to order-success page. But logic in the guard doesn’t allow the user to be redirected to order-success page instead user gets redirected to tabs page

So how to bypass this url in the guard so that user will go to order-success page

Thank you in advance


export class AuthGuard implements CanActivate   {
  constructor(public auth: AuthenticationService, public router : Router,) {}

  async canActivate(): Promise<boolean> {

    let auth = await this.auth.isAuthenticated() // returns true if user is authenticated else false
    if(auth) {
      return true;
    else {
      return false;


{ path: '', redirectTo: 'tabs', pathMatch: 'full' },

    path: 'tabs', canActivate: [AuthGuard],
    loadChildren: () => import('./pages/tabbar/tabbar.module').then( m => m.TabbarPageModule)

    path: 'order-success',
    loadChildren: () => import('./pages/order-success/order-success.module').then(m => m.OrderSuccessPageModule)

Im not sure I understand? What is the express server returning? What have you tried? There’s a sample here for the tabs page, but nothing regarding the order-success.

It doesn’t even appear that they are in the same route, so not sure what needs to get by-passed.

Its related payment gateway. Express server validates payment and redirect user to order-success page like
Order-success and tabs are not in same route.
I tried using router.url to get url and then redirect but it is not working

In stead of returning a redirect, why not sure return a status and then handle redirects in the client app.

This is what I do everytime. But in case of my payment gateway Razorpay , they posts payment related data to your server, you have to generate signature to validate payment and redirect user. I confirmed with them.

i am using this
serv is a service

  if (!this.serv.islogin) {


  } else {

  return this.serv.islogin

or you can use this code
// return this.serv.auth().pipe(

  //   map(res => {

  //     console.log(res['auth'])

  //     if (res['auth']) {

  //       return true;

  //     } else {

  //       this.route.navigate(['login'])

  //       return false;

  //     }

  //   }),

  //   catchError((err) => {

  //     return of(false);

  //   })

  // );