'Angular13 window.location.assign('/error.html') not working

I am trying to load an html file outside app folder, but in the same path where index.html located, with window.location.assign('/error.html') same error shows when router.navigateByUrl('/error.html');

Scenario, to redirect the page to an error page when the login failed. External file created to skip from the main router outlet.

this.auth.getUser(userId).subscribe((user)=>{
    if(user){
    this.router.navigate(['main']);
   else{ 
     window.location.assign('/error.html');
   }

 })


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source