防止 Angular NTLM 实现被 zone.js 阻止

问题描述

我正在尝试通过 NTLM 实现 Windows 身份验证。然而,似乎 zone.js 阻止我继续这个过程。每当我添加 withCredentials: true 等时,请求似乎都没有收到,zone.js 直接抛出一个带有基本登录提示的 401。我可以防止 zone.js 抛出这些类型的错误吗?

我现在的 AuthInterceptorService 看起来像这样

import { Injectable } from '@angular/core';
import { HttpInterceptor,HttpRequest,HttpHandler,HttpResponse } from '@angular/common/http';
import { GlobalObservalStateService } from 'src/app/services/globalObserval-state.service';
import { exhaustMap,take,tap } from 'rxjs/operators';
import { User } from 'src/app/models/user.model';
import { Router } from '@angular/router';

@Injectable()
export class AuthInterceptorService implements HttpInterceptor {
  constructor(
    private readonly globalObservalStateService: GlobalObservalStateService,private router: Router
  ){}

  intercept(req: HttpRequest<any>,next: HttpHandler): any {
    return this.globalObservalStateService.getUser().pipe(
      take(1),exhaustMap((user: User) => {
          return next.handle(req)
          .pipe(
            tap<HttpResponse<any>>(
                res => {
                    // Logic if response is ok
                    console.log(res);
                },err => {
                    // Logic if response is not ok
                    console.log(err);
                    if(err.status === 401) {
                        console.log('401')
                    }
                }
            )
          )
      })
    )
  }
}

当前错误如下

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)