How to handle unauthorized requests(status with 401 or 403) with new httpClient in angular 4.3
You should use your interceptor and just handle it like this: @Injectable() export class AuthInterceptor implements HttpInterceptor { constructor(private router: Router) { } private handleAuthError(err: HttpErrorResponse): Observable<any> { //handle your auth error or rethrow if (err.status === 401 || err.status === 403) { //navigate /delete cookies or whatever this.router.navigateByUrl(`/login`); // if you’ve caught / handled … Read more