We have an angular 11 app deployed as Azure Static Web App. The Auth Guard is implemented and WORKING IN LOCAL that means running in VS with F5 everything is fine. However, on Azure, trying to access an unauthorized page result in a 404 not found rather than the redirection to the login page as it is implemented.
Here's the AuthGuard component:
import { Injectable } from "@angular/core";
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from "@angular/router";
import { AuthenticationService } from "../services/authentication.service";
@Injectable({
providedIn: "root"
})
export class AuthGuard implements CanActivate {
constructor(private router: Router, private authenticationService: AuthenticationService) { }
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
if (this.authenticationService.currentTokenValue) {
return true;
}
void this.router.navigate(["/account/login"]);
return false;
}
}
The way we test locally is to run the app then open another tab and go to a page without login first and we're redirected to the login page as expected.
Are we missing something somewhere for the redirection to work on Azure?