Search code examples
angulartomcatnavigationhttpserver

angular 4 app deployed on tomcat not rerouting properly after okta authentication


I have deployed my angular 4 app in tomcat server, but after authenticating with okta, it is not redirecting other page even though I am using navigateByUrl().

But the same works on node js when running ng serve command.

showProductsPage(){ 
   this.router.navigateByUrl('/products');}  
   showLogin() {
      this.oktaSignIn.renderEl({el: '#okta-login-container'}, (response) 
      if (response.status === 'SUCCESS') {
        this.user = response.claims.email;
        this.oktaSignIn.session.get((sessionResponse) => {
            this.userId = sessionResponse.login.indexOf('@') > -1 ? sessionResponse.login.split("@")[0] : sessionResponse.login;
            localStorage.setItem('tkid',this.userId);
            this.showProductsPage();
            //this.router.navigate(['products']);
        }); 
    }

I Tried with HashLocationStrategy but not sure how it can help me in this scenario


Solution

  • I have implemented

    import {HashLocationStrategy, LocationStrategy} from '@angular/common'; -useHash:true in the imports -{provide: LocationStrategy,useClass:HashLocationStrategy}

    Basically this is an error on okta side, but using HashLocationStrategy I solved this